Secrets of Kafka console producers

Do Kafka console producers can also create topics? Tricky Interview Ques.

Yes, it is possible to create a topic using console producer. But this is really a bad idea to create a topic. Read the blog below for details.

Do Kafka console producers can also create topics?

kafka-console-producer.sh --bootstrap-server 127.0.0.1:9092 --topic new_topic

But basically this new_topic does not exist, it is not yet created in Kafka, and what will happen if we send the message?

We have got the warning stating that the Leader is not available. This doesn’t work, so let’s try one more time.

This is the issue in Kafka.

Earlier there was no leader available but the Producers are able to recover from the errors. So it just tried and waited until the leader was available and then produced the message.

Checking the list of topics now.

Is it a good idea to create topics in this way?

kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic new_topic --describe

Learn how can you create a Topic…

Next →

Software Engineer at HCL | Technical Content Writing | Follow me on LinkedIn https://www.linkedin.com/in/sagarkudu/