From: Kai Moritz Date: Wed, 3 Aug 2022 19:48:31 +0000 (+0200) Subject: Überarbeitungen von Setup/Übung aus Branch 'rest-producer' gemerged X-Git-Tag: customized---lvm-2-tage X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ece4cdf8b47768f518c21aea12bcd0dadc7c91e1;p=demos%2Fkafka%2Ftraining Überarbeitungen von Setup/Übung aus Branch 'rest-producer' gemerged * Überarbeitungen an die Übung 'customized' angepasst. --- ece4cdf8b47768f518c21aea12bcd0dadc7c91e1 diff --cc README.sh index ece13d0,d2dccf8..d0a59bd --- a/README.sh +++ b/README.sh @@@ -24,83 -24,39 +24,43 @@@ f 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 -d kafka-ui - - docker-compose exec -T cli bash << 'EOF' - echo "Creating topic with 3 partitions..." - kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test - # tag::createtopic[] - kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 3 - # end::createtopic[] - kafka-topics --bootstrap-server kafka:9092 --describe --topic test - EOF - - docker-compose up -d producer-0 producer-1 consumer - - while ! [[ $(http -b :8000/actuator/health | jq -r .status) =~ "UP" ]]; do echo Waiting for :8000/actuator/health; sleep 1; done - while ! [[ $(http -b :8001/actuator/health | jq -r .status) =~ "UP" ]]; do echo Waiting for :8001/actuator/health; sleep 1; done - while ! [[ $(http -b :8081/actuator/health | jq -r .status) =~ "UP" ]]; do echo Waiting for :8081/actuator/health; sleep 1; done + docker-compose up setup -docker-compose up -d ++docker-compose up -d producer-0 producer-1 ++while ! [[ $(http -b :8000/actuator/health | jq -r .status) =~ "UP" ]]; do echo Waiting for producer-0; sleep 1; done ++while ! [[ $(http -b :8001/actuator/health | jq -r .status) =~ "UP" ]]; do echo Waiting for producer-1; sleep 1; done ++docker-compose up -d consumer + +echo foo | http -v :8000/foo +echo foo | http -v :8001/foo ++echo foo | http -v :8001/foo ++echo foo | http -v :8000/bar ++echo foobar | http -v :8000/bar ++echo foofoo | http -v :8000/bar ++echo barbar | http -v :8000/bar ++echo barfoo | http -v :8000/bar ++echo bar | http -v :8000/bar - sleep 5 -while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer..."; sleep 1; done -- - http -v :8081/seen -echo foo | http -v :8080/bar -echo bar | http -v :8080/foo -echo foobar | http -v :8080/bar -dd if=/dev/zero bs=1024 count=1024 | http -v :8080/bar -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo -echo foofoo | http -v :8080/bar -echo barbar | http -v :8080/foo - -docker-compose logs producer + docker-compose logs consumer + +docker-compose up -d - - sleep 5 - - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen ++docker-compose exec cli kafkacat -C -b kafka:9092 -t test -o 0 -f'p=%p|o=%o|k=%k|v=%s\n' -q -c20 + +docker-compose exec -T cli bash << 'EOF' +echo "Altering number of partitions from 3 to 7..." ++kafka-topics --bootstrap-server kafka:9092 --describe --topic test ++kafka-topics --bootstrap-server kafka:9092 --describe --topic test +kafka-topics --bootstrap-server kafka:9092 --alter --topic test --partitions 7 +kafka-topics --bootstrap-server kafka:9092 --describe --topic test +EOF + +docker-compose restart producer-0 producer-1 - +while ! [[ $(http -b :8000/actuator/health | jq -r .status) =~ "UP" ]]; do echo Waiting for :8000/actuator/health; sleep 1; done +while ! [[ $(http -b :8001/actuator/health | jq -r .status) =~ "UP" ]]; do echo Waiting for :8001/actuator/health; sleep 1; done - - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - sleep 1 - http -v :8081/seen - - docker-compose stop ++docker-compose exec cli kafkacat -C -b kafka:9092 -t test -o 0 -f'p=%p|o=%o|k=%k|v=%s\n' -q -c20 ++ ++echo "Messages from peter" ++docker-compose logs consumer | grep k=peter ++echo "Messages from beate" ++docker-compose logs consumer | grep k=beate ++echo "Messages from foo" ++docker-compose logs consumer | grep k=foo diff --cc docker-compose.yml index fe1ad42,7ae8d9b..11c5c8d --- a/docker-compose.yml +++ b/docker-compose.yml @@@ -45,66 -82,7 +82,59 @@@ services producer.bootstrap-server: kafka:9092 producer.client-id: producer producer.topic: test + producer.partition: 0 + + producer-1: + image: juplo/rest-producer:1.0-SNAPSHOT + ports: + - 8001:8080 + environment: + server.port: 8080 + producer.bootstrap-server: kafka:9092 + producer.client-id: producer + producer.topic: test + producer.partition: 1 + + peter: + image: juplo/rest-client:1.0-SNAPSHOT + environment: + server.port: 8080 + rest-client.baseUrl: http://producer-1: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-1: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-0: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-1: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-0:8080 + rest-client.username: uschi + rest-client.throttle-ms: 1200 consumer: - image: juplo/endless-consumer:1.0-SNAPSHOT - ports: - - 8081:8080 - environment: - server.port: 8080 - consumer.bootstrap-server: kafka:9092 - consumer.client-id: my-group - consumer.client-id: consumer - consumer.topic: test + image: juplo/toolbox + command: kafkacat -C -b kafka:9092 -t test -o 0 -f'p=%p|o=%o|k=%k|v=%s\n'