Produce and consume messages from a Kafka topic using docker

version: '3'services:  zookeeper:      image: wurstmeister/zookeeper      container_name: zookeeper      ports:        - "2181:2181"  kafka:     image: wurstmeister/kafka     container_name: kafka     ports:       - "9092:9092"     environment:       KAFKA_ADVERTISED_HOST_NAME: localhost       KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
docker-compose up
docker-compose up -d
docker exec -it kafka /bin/sh
cd /opt/kafka/bin/
kafka-topics.sh --bootstrap-server localhost:9092  --topic myFirstTopic --create
kafka-topics.sh --list --bootstrap-server localhost:9092
kafka-topics.sh --bootstrap-server localhost:9092  --delete --topic myFirstTopic
kafka-console-producer.sh  --bootstrap-server localhost:9092  --topic myFirstTopic
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic myFirstTopic --from-beginning

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store