From a30fdb455b638e63e0e2084ad916cadb1d44f108 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 9 Aug 2022 19:19:16 +0200 Subject: [PATCH] WIP --- README.sh | 43 ++++++++----------------------------------- docker-compose.yml | 44 ++++++++++++++------------------------------ 2 files changed, 22 insertions(+), 65 deletions(-) diff --git a/README.sh b/README.sh index 3bc7e8a..6440022 100755 --- a/README.sh +++ b/README.sh @@ -1,7 +1,5 @@ #!/bin/bash -IMAGE=juplo/rest-producer:1.0-SNAPSHOT - if [ "$1" = "cleanup" ] then docker-compose down -v @@ -10,48 +8,23 @@ fi docker-compose up -d zookeeper kafka-1 kafka-2 kafka-3 cli -if [[ - $(docker image ls -q $IMAGE) == "" || - "$1" = "build" -]] -then - mvn install || exit -else - echo "Using image existing images:" - docker image ls $IMAGE -fi - echo "Waiting for the Kafka-Cluster to become ready..." 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 - -while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for acks-1..."; sleep 1; done -while ! [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for acks-all..."; sleep 1; done -# tag::foo[] -echo foo | http -v :8081/acks-1 -echo foo | http -v :8082/acks-all -kafkacat -C -b :9092 -t test -o 0 -e -f'p=%p|o=%o|k=%k|v=%s\n' -# end::foo[] +docker-compose up producer +docker-compose up consumer -# tag::stop[] docker-compose stop kafka-1 docker-compose exec cli kafka-topics --bootstrap-server kafka:9092 --describe --topic test -# end::stop[] -time echo bar | http -v :8081/acks-1 -time echo bar | http -v :8081/acks-1 -time echo bar | http -v :8082/acks-all -time echo bar | http -v :8082/acks-all -sleep 1 -kafkacat -C -b :9092 -t test -o 0 -e -f'p=%p|o=%o|k=%k|v=%s\n' +docker-compose up producer +docker-compose up consumer docker-compose stop kafka-3 docker-compose exec cli kafka-topics --bootstrap-server kafka:9092 --describe --topic test -time echo foobar | http -v :8081/acks-1 -time echo foobar | http -v :8081/acks-1 -time echo foobar | http -v :8082/acks-all -sleep 1 -kafkacat -C -b :9092 -t test -o 0 -e -f'p=%p|o=%o|k=%k|v=%s\n' +docker-compose up producer +docker-compose up consumer +docker-compose up consumer +docker-compose up consumer diff --git a/docker-compose.yml b/docker-compose.yml index f3614d5..b50ebc1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,6 +60,10 @@ services: depends_on: - zookeeper + cli: + image: confluentinc/confluent-cli:7.1.3 + command: sleep infinity + setup: image: juplo/toolbox command: > @@ -70,36 +74,16 @@ services: kafka-topics --bootstrap-server kafka-1:9092 --describe --topic test kafka-topics --bootstrap-server kafka-2:9092 --describe --topic test kafka-topics --bootstrap-server kafka-3:9092 --describe --topic test - kafka-topics --bootstrap-server kafka:9092 --describe --topic test | kafkacat -P -b kafka:9092 -t test -X acks=all - kafkacat -C -b kafka:9092 -t test -o 0 -e " - - cli: - image: juplo/toolbox - command: sleep infinity - - acks-all: - image: juplo/rest-producer:1.0-SNAPSHOT - ports: - - 8082:8080 - environment: - server.port: 8080 - 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: - server.port: 8080 - producer.bootstrap-server: kafka:9092 - producer.client-id: acks-1 - producer.topic: test - producer.acks: 1 + producer: + image: confluentinc/cp-kafkacat:7.1.3 + command: > + bash -c " + echo 'hello world' | kafkacat -P -b kafka:9092 -t test -X acks=all + echo 'hello world' | kafkacat -P -b kafka:9092 -t test -X acks=all + echo 'hello world' | kafkacat -P -b kafka:9092 -t test -X acks=all + " consumer: - image: juplo/toolbox - command: kafkacat -C -b kafka:9092 -t test -o 0 -f'p=%p|o=%o|k=%k|v=%s\n' + image: confluentinc/cp-kafkacat:7.1.3 + command: kafkacat -C -b kafka:9092 -t test -o 0 -e -f'p=%p|o=%o|k=%k|v=%s\n' -- 2.20.1