This repository contains an example how to setup Apache Kafka containerized with docker-compose and how to communicate with it via Node.js.
Clone and open the repository.
To run Kafka and Zookeeper, execute in your terminal:
docker-compose up -d
npm install
Run
node producer.js
to start the producer process. Type a message in the Console. The first message will be ommited to create the topic. The next messages you enter will be published in Kafka in the configured topic.
Open another terminal.
Run
node consumer.js
to listen to the configured topic. All messages typed in the producer terminal will appear here.