From 36c62e2eb6bbc1869626aac55bc39f2787dbee3e Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 2 Aug 2022 22:01:35 +0200 Subject: [PATCH] =?utf8?q?Compose-Setup=20an=20das=20aus=20den=20Producer-?= =?utf8?q?=C3=9Cbungen=20angepasst?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Es wird jetzt der Rest-Producer verwendet. * Um die Nachrichten zu erzeugen, werden die Rest-Clients verwendet. * Ziel: Dies ist näher an dem Setup aus den Wordcount-Übungen. * Versucht das Timing in dem README-Skript unabhängiger von Timing-Fragen zu machen - scheitert aber daran, dass das Skript nicht gezielt darauf warten kann, dass das neu angelegte Topic zur Verfügung steht. --- README.sh | 9 ++++++--- docker-compose.yml | 50 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/README.sh b/README.sh index b1ba0be..8915acf 100755 --- a/README.sh +++ b/README.sh @@ -26,11 +26,14 @@ 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 up -d -sleep 5 -docker-compose exec cli kafkacat -b kafka:9092 -t test -q -c 20 -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n' +while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer..."; sleep 1; done +sleep 5 +docker-compose exec cli kafkacat -b kafka-2:9092 -t test -q -c 10 -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n' +docker-compose exec cli kafkacat -b kafka-2:9092 -t test -q -c 10 -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n' +docker-compose exec cli kafkacat -b kafka-2:9092 -t test -q -c 10 -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n' -docker-compose stop producer consumer-1 consumer-2 consumer-3 +docker-compose stop peter klaus beate franz uschi consumer-1 consumer-2 consumer-3 docker-compose logs consumer-1 docker-compose logs consumer-2 docker-compose logs consumer-3 diff --git a/docker-compose.yml b/docker-compose.yml index 6ab0d1b..449e2ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,8 +74,54 @@ services: command: sleep infinity producer: - image: juplo/simple-producer:1.0-SNAPSHOT - command: producer + image: juplo/rest-producer:1.0-SNAPSHOT + ports: + - 8080:8080 + environment: + server.port: 8080 + producer.bootstrap-server: kafka:9092 + producer.client-id: producer + producer.topic: test + + peter: + image: juplo/rest-client:1.0-SNAPSHOT + environment: + server.port: 8080 + rest-client.baseUrl: http://producer:8080 + rest-client.username: peter + rest-client.throttle-ms: 1000 + + klaus: + image: juplo/rest-client:1.0-SNAPSHOT + environment: + server.port: 8080 + rest-client.baseUrl: http://producer:8080 + rest-client.username: klaus + rest-client.throttle-ms: 1100 + + beate: + image: juplo/rest-client:1.0-SNAPSHOT + environment: + server.port: 8080 + rest-client.baseUrl: http://producer:8080 + rest-client.username: beate + rest-client.throttle-ms: 900 + + franz: + image: juplo/rest-client:1.0-SNAPSHOT + environment: + server.port: 8080 + rest-client.baseUrl: http://producer:8080 + rest-client.username: franz + rest-client.throttle-ms: 800 + + uschi: + image: juplo/rest-client:1.0-SNAPSHOT + environment: + server.port: 8080 + rest-client.baseUrl: http://producer:8080 + rest-client.username: uschi + rest-client.throttle-ms: 1200 consumer-1: image: juplo/simple-consumer:1.0-SNAPSHOT -- 2.20.1