From: Kai Moritz Date: Sun, 29 Jan 2023 14:25:55 +0000 (+0100) Subject: README.sh & Setup für die Übung `rest-producer--partitioning` umgestellt X-Git-Tag: rest-producer--partitioning~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=247b9d245f7b04985972baa20c2b93c8df1c0c5c;p=demos%2Fkafka%2Ftraining README.sh & Setup für die Übung `rest-producer--partitioning` umgestellt --- diff --git a/README.sh b/README.sh index 3dc3476..b0b9604 100755 --- a/README.sh +++ b/README.sh @@ -10,7 +10,7 @@ then fi docker-compose up -d kafka-1 kafka-2 kafka-3 cli -docker-compose rm -svf producer +docker-compose rm -svf producer producer-0 producer-1 if [[ $(docker image ls -q $IMAGE) == "" || @@ -24,20 +24,36 @@ else fi 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 - -# tag::success[] -echo -n 'Hallo Welt!' | http -v :8080/foo -# end::success[] - -# tag::failure[] -dd if=/dev/zero bs=1024 count=1024 | http -v :8080/bar -# end::failure[] - -# tag::timeout[] -docker-compose stop kafka-1 kafka-2 kafka-3 -echo -n 'Hallo again...' | http -v --timeout 30 :8080/foo -# end::timeout[] +docker-compose up -d producer-0 producer-1 +while ! [[ $(http 0:8000/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-0..."; sleep 1; done +while ! [[ $(http 0:8001/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-1..."; sleep 1; done +docker-compose up -d consumer + +echo -n Nachricht 1 an Producer 0 | http -v :8000/foo +echo -n Nachricht 1 an Producer 1 | http -v :8001/foo +echo -n Nachricht 2 an Producer 0 | http -v :8000/bar +echo -n Nachricht 2 an Producer 1 | http -v :8001/bar + +docker-compose logs consumer + +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 0:8000/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-0..."; sleep 1; done +while ! [[ $(http 0:8001/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-1..."; sleep 1; done + +echo -n Nachricht 3 an Producer 0 | http -v :8000/foo +echo -n Nachricht 3 an Producer 1 | http -v :8001/foo +echo -n Nachricht 4 an Producer 0 | http -v :8000/bar +echo -n Nachricht 4 an Producer 1 | http -v :8001/bar + +docker-compose logs consumer + +kafkacat -b :9092 -t test -o 0 -p0 -f'p=%p|o=%o|k=%k|v=%s\n' -qe +kafkacat -b :9092 -t test -o 0 -p1 -f'p=%p|o=%o|k=%k|v=%s\n' -qe diff --git a/docker-compose.yml b/docker-compose.yml index 195ffad..baf0d31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -116,6 +116,28 @@ services: producer.client-id: producer producer.topic: test + producer-0: + image: juplo/rest-producer:1.0-SNAPSHOT + ports: + - 8000:8080 + environment: + server.port: 8080 + producer.bootstrap-server: kafka:9092 + producer.client-id: producer-0 + 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-1 + producer.topic: test + producer.partition: 1 + consumer: image: juplo/simple-consumer:1.0-SNAPSHOT command: kafka:9092 test my-group consumer