KStream<String, String> kstream = builder.stream("input-topic");
kstream.to("output-topic");
The "input-topic" has be created. I didn't create the "output-topic" and it seems that "Kstream" created one for me along with other internal topics. Also, saw this in the javadoc of "to" function The specified topic should be manually created before it is used (i.e., before the Kafka Streams application is started
So my question is that do we always have to manually create the "output-topic"?
By default, kafka broker config auto.create.topics.enable
gets set to true, allowing clients attempting to produce/consume from an unknown topic to create it and begin their process. In Kafka, it's best practice to explicitly create your topics before doing anything with them. This is to ensure you don't unintentionally create an overflow of topics, as well as to ensure topics are set with the right partition/replication-factor count. Hence, why the documentation states - should be manually created before it is used`.
The answer is no, we don't always have to manually create topics, especially when working in local environment / playing around.
NOTE: if topics are getting created on the fly (i.e. on consumer/producer start up), the partition/replication-factor gets set to what you've got within the server.properties
file.