Kafka - kafka-console-producer

> Data Integration Tool (ETL/ELT) > Kafka (Event Hub)

1 - About

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

Advertising

3 - Example

  • 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 127.0.0.1:9092 --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.'"