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?
— Yes, it is possible but not a good idea to create a topic in this way.
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.
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.
kafka-topics.sh --zookeeper 127.0.0.1:2181 --list
Is it a good idea to create topics in this way?
No, really it is very bad to create a topic in this way, the problem is we get only one partition count and only one replication factor.
kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic new_topic --describe
Learn how can you create a Topic…
1. How to create Topics with Partitions & Replication factor using Kafka?
Kafka maintains feeds of messages in categories called topics.