sleep 1
docker compose -f docker/docker-compose.yml logs setup
-echo
-echo "Hilfe-Ausgabe von kafkacat"
-echo
-docker compose -f docker/docker-compose.yml exec -T cli kafkacat -h
-echo
-echo "Nachrichten schreiben mit kafkacat"
-echo
-docker compose -f docker/docker-compose.yml exec -T cli kafkacat -P -b kafka:9092 -t test << EOF
-Hallo Welt!
-Nachricht #1
-Nachricht #2
-Nachricht #3
-EOF
-echo
-echo "Nachrichten lesen mit kafkacat"
-echo
-docker compose -f docker/docker-compose.yml exec cli kafkacat -C -b kafka:9092 -t test -o beginning -e
+docker compose -f docker/docker-compose.yml up -d producer
+docker compose -f docker/docker-compose.yml up -d consumer
+
+sleep 5
+docker compose -f docker/docker-compose.yml stop consumer
+
+docker compose -f docker/docker-compose.yml start consumer
+sleep 5
+
+docker compose -f docker/docker-compose.yml stop producer consumer
+docker compose -f docker/docker-compose.yml logs consumer
version: '3.2'
services:
- zookeeper:
+ zookeeper-1:
image: confluentinc/cp-zookeeper:7.7.1
environment:
+ ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
+ ZOOKEEPER_SERVERS: zookeeper-1:2888:3888;zookeeper-2:2888:3888;zookeeper-3:2888:3888
ports:
- 2181:2181
volumes:
- - zookeeper-data:/var/lib/zookeeper/data
- - zookeeper-log:/var/lib/zookeeper/log
+ - zookeeper-1-data:/var/lib/zookeeper/data
+ - zookeeper-1-log:/var/lib/zookeeper/log
+
+ zookeeper-2:
+ image: confluentinc/cp-zookeeper:7.7.1
+ environment:
+ ZOOKEEPER_SERVER_ID: 2
+ ZOOKEEPER_CLIENT_PORT: 2181
+ ZOOKEEPER_SERVERS: zookeeper-1:2888:3888;zookeeper-2:2888:3888;zookeeper-3:2888:3888
+ ports:
+ - 2182:2181
+ volumes:
+ - zookeeper-2-data:/var/lib/zookeeper/data
+ - zookeeper-2-log:/var/lib/zookeeper/log
+
+ zookeeper-3:
+ image: confluentinc/cp-zookeeper:7.7.1
+ environment:
+ ZOOKEEPER_SERVER_ID: 3
+ ZOOKEEPER_CLIENT_PORT: 2181
+ ZOOKEEPER_SERVERS: zookeeper-1:2888:3888;zookeeper-2:2888:3888;zookeeper-3:2888:3888
+ ports:
+ - 2183:2181
+ volumes:
+ - zookeeper-3-data:/var/lib/zookeeper/data
+ - zookeeper-3-log:/var/lib/zookeeper/log
kafka-1:
image: confluentinc/cp-kafka:7.7.1
environment:
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ KAFKA_ZOOKEEPER_CONNECT: zookeeper-1:2181
KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9081
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, LOCALHOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: BROKER://kafka-1:9092, LOCALHOST://localhost:9081
- 9081:9081
stop_grace_period: 120s
depends_on:
- - zookeeper
+ - zookeeper-1
kafka-2:
image: confluentinc/cp-kafka:7.7.1
environment:
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ KAFKA_ZOOKEEPER_CONNECT: zookeeper-2:2181
KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9082
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, LOCALHOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: BROKER://kafka-2:9092, LOCALHOST://localhost:9082
- kafka
stop_grace_period: 120s
depends_on:
- - zookeeper
+ - zookeeper-2
kafka-3:
image: confluentinc/cp-kafka:7.7.1
environment:
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ KAFKA_ZOOKEEPER_CONNECT: zookeeper-3:2181
KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9083
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, LOCALHOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: BROKER://kafka-3:9092, LOCALHOST://localhost:9083
- 9083:9083
stop_grace_period: 120s
depends_on:
- - zookeeper
+ - zookeeper-3
schema-registry:
image: confluentinc/cp-schema-registry:7.7.1
kafka-topics --bootstrap-server kafka:9092 \
--create \
--topic test \
- --partitions 2 \
+ --partitions 1 \
--replication-factor 3 \
--config min.insync.replicas=2 \
&& echo Das Topic \'test\' wurde erfolgreich angelegt: \
environment:
HTTP_PORT: 80
CONNECTION_JUPLO_NAME: juplo
- CONNECTION_JUPLO_CONN: zookeeper:2181
+ CONNECTION_JUPLO_CONN: zookeeper-1:2181
AUTO_CONNECT_CONNECTION_ID: JUPLO
depends_on:
- - zookeeper
+ - zookeeper-1
+ - zookeeper-2
+ - zookeeper-3
akhq:
image: tchiotludo/akhq:0.23.0
- kafka-2
- kafka-3
+ producer:
+ image: juplo/simple-producer:1.0-SNAPSHOT
+ command: kafka:9092 test producer
+
+ consumer:
+ image: juplo/simple-consumer:1.0-SNAPSHOT
+ command: kafka:9092 test my-group consumer
+
volumes:
- zookeeper-data:
- zookeeper-log:
+ zookeeper-1-data:
+ zookeeper-1-log:
+ zookeeper-2-data:
+ zookeeper-2-log:
+ zookeeper-3-data:
+ zookeeper-3-log:
kafka-1-data:
kafka-2-data:
kafka-3-data: