Kafka - kafka-console-producer


kafka-console-producer is a producer command line tool to read data from standard input and write it to a Kafka topic.


  • From the command line:
kafka-console-producer --broker-list kafka02.example.com:9092,kafka03.example.com:9092 --topic t1

# or
readfile whatEver.json | kafka-console-producer --broker-list --topic topicname
  • With docker-compose and a kafka services
docker-compose exec kafka  bash -c "seq 42 | kafka-console-producer --request-required-acks 1 --broker-list localhost:29092 --topic foo && echo 'Produced 42 messages.'"

Powered by ComboStrap