exit
fi
-docker-compose up -d zookeeper kafka cli
+docker-compose up -d zookeeper kafka-1 kafka-2 kafka-3 cli
if [[
$(docker image ls -q $IMAGE) == "" ||
fi
echo "Waiting for the Kafka-Cluster to become ready..."
-docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1
+docker-compose exec cli cub kafka-ready -b kafka:9092 3 60 > /dev/null 2>&1 || exit 1
docker-compose up setup
docker-compose up -d
-sleep 15
+sleep 10
+echo foo | http -v :8080/foo-acks-0
+echo foo | http -v :8081/foo-acks-1
+echo foo | http -v :8082/foo-acks-all
+http -v :8000/seen
-docker-compose stop producer consumer
+docker-compose stop kafka-1
+
+echo bar | http -v :8080/bar-acks-0
+echo bar | http -v :8081/bar-acks-1
+echo bar | http -v :8082/bar-acks-all
+http -v :8000/seen
+
+docker-compose stop kafka-3
+
+echo foobar | http -v :8080/foobar-acks-0
+echo foobar | http -v :8081/foobar-acks-1
+echo foobar | http -v :8082/foobar-acks-all
+http -v :8000/seen
+
+dd if=/dev/zero bs=4096 count=1 | http -v :8082/to-big-acks-all
+dd if=/dev/zero bs=4096 count=1 | http -v :8081/to-big-acks-1
+dd if=/dev/zero bs=4096 count=1 | http -v :8080/to-big-acks-0
+http -v :8000/seen
+
+docker-compose stop kafka-2
+
+echo nirvana | http -v :8080/nirvana-acks-0
+http -v :8000/seen
+
+docker-compose stop acks-all acks-1 acks-0 consumer
ports:
- 2181:2181
- kafka:
+ kafka-1:
image: confluentinc/cp-kafka:7.0.2
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9081
+ KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka-1:9092, LOCALHOST://localhost:9081
+ KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER
+ KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT
+ KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
+ KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
+ ports:
+ - 9081:9081
+ depends_on:
+ - zookeeper
+
+ kafka-2:
+ image: confluentinc/cp-kafka:7.0.2
+ environment:
+ KAFKA_BROKER_ID: 2
+ KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9082
- KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka:9092, LOCALHOST://localhost:9082
+ KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka-2:9092, LOCALHOST://localhost:9082
KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
+ KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
ports:
- 9092:9082
- 9082:9082
+ networks:
+ default:
+ aliases:
+ - kafka
+ depends_on:
+ - zookeeper
+
+ kafka-3:
+ image: confluentinc/cp-kafka:7.0.2
+ environment:
+ KAFKA_BROKER_ID: 3
+ KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9083
+ KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka-3:9092, LOCALHOST://localhost:9083
+ KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER
+ KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT
+ KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
+ KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
+ ports:
+ - 9083:9083
depends_on:
- zookeeper
command: >
bash -c "
kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test
- kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2
+ kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 1 --replication-factor 3 --config min.insync.replicas=2 --config max.message.bytes=1024
+ kafka-topics --bootstrap-server kafka:9092 --describe --topic test
"
cli:
image: juplo/toolbox
command: sleep infinity
- producer:
+ acks-all:
+ image: juplo/rest-producer:1.0-SNAPSHOT
+ ports:
+ - 8082:8080
+ environment:
+ producer.bootstrap-server: kafka:9092
+ producer.client-id: acks-all
+ producer.topic: test
+ producer.acks: all
+
+ acks-1:
+ image: juplo/rest-producer:1.0-SNAPSHOT
+ ports:
+ - 8081:8080
+ environment:
+ producer.bootstrap-server: kafka:9092
+ producer.client-id: acks-1
+ producer.topic: test
+ producer.acks: 1
+
+ acks-0:
image: juplo/rest-producer:1.0-SNAPSHOT
ports:
- 8080:8080
environment:
producer.bootstrap-server: kafka:9092
- producer.client-id: producer
+ producer.client-id: acks-0
producer.topic: test
+ producer.acks: 0
consumer:
image: juplo/counting-consumer:1.0-SNAPSHOT
ports:
- - 8081:8081
+ - 8000:8081
environment:
consumer.bootstrap-server: kafka:9092
consumer.client-id: my-group