This tutorial describes how to disable automatic Topcis creation at the time of producing messages in Apache Kafka
Apache Kafka, by default, comes with a setting that enables automatic creation of a Topic at the time of publishing message itself. For example, if you intend to send a message to a topic named 'tutorials_log' and that topic does not exist in Kafka yet, you can simply start sending messages to it using producer as Kafka will create it automatically for you.
While this behaviour is much of a convenience in dev and test environments, it is not recommended for production environment clusters. In the next section, we will see how we can disable automatic creation of topic.
Disabling Automatic Topic Creation
Automatic topic creation setting is a Kafka broker level setting and you will need to apply it in all of your brokers' configuration files(properties files starting with server).
Finally, here is how you can disable it -
Once you have added above configuration to your brokers' properties files, restart all the brokers one by one to make this setting active.
Please note that if you are using Kafka from Confluent platform, automatic topic creation is already disabled for you.
Thank you for reading through the tutorial. In case of any feedback/questions/concerns, you can communicate same to us through your comments and we shall get back to you as soon as possible.