Created
June 7, 2025 11:34
-
-
Save amcginlay/574db83723d3f63405231aa75d7bff29 to your computer and use it in GitHub Desktop.
kafka-producer-consumer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create topic | |
# docker exec -it kafka bash -c "kafka-topics.sh --create --topic hello-topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1" | |
# create consumer (with group, blocks on stdout) | |
# docker exec -it kafka bash -c "kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic hello-topic --group hello-group --from-beginning" | |
# create producer (one message via stdin) | |
# docker exec -it kafka bash -c "echo "test" | kafka-console-producer.sh --bootstrap-server localhost:9092 --topic hello-topic" | |
services: | |
kafka: | |
image: bitnami/kafka:latest | |
container_name: kafka | |
environment: | |
- KAFKA_CFG_NODE_ID=1 | |
- KAFKA_CFG_PROCESS_ROLES=controller,broker | |
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 | |
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092 | |
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER | |
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@kafka:9093 | |
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT | |
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT | |
- ALLOW_PLAINTEXT_LISTENER=yes | |
ports: | |
- "9092:9092" | |
kafdrop: | |
image: obsidiandynamics/kafdrop:latest | |
container_name: kafdrop | |
environment: | |
- KAFKA_BROKERCONNECT=kafka:9092 | |
- JVM_OPTS=-Xms32M -Xmx64M | |
ports: | |
- "9000:9000" | |
depends_on: | |
- kafka |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment