From afe6ed701888b20b659d1a788108a842c7307f09 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 23 Nov 2022 04:48:40 +0100 Subject: [PATCH] =?utf8?q?Verbesserungen=20&=20Korrekturen=20aus=20rest-pr?= =?utf8?q?oducer=20=C3=BCbernommen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.sh | 14 ++++++-------- docker-compose.yml | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.sh b/README.sh index 52b5f20..0e8d4d3 100755 --- a/README.sh +++ b/README.sh @@ -4,28 +4,27 @@ IMAGE=juplo/rest-producer-json:1.0-SNAPSHOT if [ "$1" = "cleanup" ] then - docker-compose down -v + docker-compose down -v --remove-orphans mvn clean exit fi -docker-compose up -d kafka-0 kafka-1 kafka-2 kafka-3 cli +docker-compose up -d kafka-1 kafka-2 kafka-3 cli +docker-compose rm -svf producer if [[ $(docker image ls -q $IMAGE) == "" || "$1" = "build" ]] then - docker-compose rm -svf producer mvn clean 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 1 60 > /dev/null 2>&1 || exit 1 docker-compose up setup +docker-compose ps docker-compose up -d producer while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer..."; sleep 1; done @@ -33,9 +32,8 @@ while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Wait docker-compose up -d peter klaus sleep 10 -docker-compose stop peter klaus +docker-compose kill -s9 peter klaus -# end::http[] # tag::kafkacat[] -docker-compose exec cli kafkacat -b kafka:9092 -t test -f "%p|%o|%k=%s|%h\n" -e +kafkacat -b :9092 -t test -o 0 -e -f 'p=%p|o=%o|k=%k|h=%h|v=%s\n' # end::kafkacat[] diff --git a/docker-compose.yml b/docker-compose.yml index 175eed5..a6905a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,8 @@ services: KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false" ports: - 9081:9081 + depends_on: + - kafka-0 kafka-2: image: bitnami/kafka:3.3.1 @@ -58,6 +60,8 @@ services: default: aliases: - kafka + depends_on: + - kafka-0 kafka-3: image: bitnami/kafka:3.3.1 @@ -77,6 +81,9 @@ services: KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false" ports: - 9083:9083 + depends_on: + - kafka-0 + setup: image: juplo/toolbox @@ -86,10 +93,18 @@ services: kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 --replication-factor 3 --config min.insync.replicas=2 kafka-topics --bootstrap-server kafka:9092 --describe --topic test " + depends_on: + - kafka-1 + - kafka-2 + - kafka-3 cli: image: juplo/toolbox command: sleep infinity + depends_on: + - kafka-1 + - kafka-2 + - kafka-3 producer: image: juplo/rest-producer-json:1.0-SNAPSHOT @@ -124,5 +139,5 @@ services: " 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: juplo/simple-consumer:1.0-SNAPSHOT + command: kafka:9092 test my-group consumer -- 2.20.1