Skip to content
Kafka Is Fun

BeginnerOperations

What is the difference between kafka-console-producer and kafka-console-consumer?

Reference answer

kafka-console-producer.sh is a CLI tool that reads lines you type on stdin and writes them to a topic; by default each line becomes a separate event. The Apache quickstart runs it as: bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092. kafka-console-consumer.sh is the other direction: it reads events from a topic and prints them to stdout. With --from-beginning it starts from the earliest events still stored in the topic rather than only new ones. You can stop either one with Ctrl-C, and you can run the consumer again to read the same stored events repeatedly. They ship with the Kafka distribution and are handy for trying things out, manual testing and debugging.

Expected key concepts: kafka-console-producer, kafka-console-consumer, CLI, stdin, stdout, event, from-beginning, bootstrap-server, testing, debugging

How did that feel?

Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.