What is the bestway to create topics in kafka?
In the new producer API, when i try to publish a message to a non existing topic , it first time fails and then successfully publishing.
When you are starting your Kafka broker you can define set of properties in conf/server.properties
file. This file is just key value property file. One of the properties is auto.create.topics.enable
, if it's set to true (by default) Kafka will create topics automatically when you send messages to non-existing topics.
All config options you can find are defined here. IMHO, a simple rule for creating topics is the following: number of replicas cannot be more than the number of nodes that you have. Number of topics and partitions is unaffected by the number of nodes in your cluster
for example: