Demonstrating use of Kafka using Node and Docker
One can use the docker compose (docker-compose up --build
)to spin up everything or spin the services individually
Run the docker command
docker run --name=zookeeper -p 2181:2181 zookeeper
The default port for zookeeper is 2181
Run the docker command
docker run --name kafka-server -p 9092:9092 -e KAFKA_ZOOKEEPER_CONNECT= localhost:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 confluent/cp-kafka
node producer.js message-that-you-want-to-send
node consumer.js