From 7a3c84f739a901e6b6045ad17975b9b22144ae31 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 2 Apr 2022 19:42:09 +0200 Subject: [PATCH] =?utf8?q?Setup=20f=C3=BCr=20den=20Vergleich=20der=20Parti?= =?utf8?q?tionierungs-Methoden?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.sh | 69 ++++++++++++++++++++++++++++++++++++++++++---- docker-compose.yml | 29 +++++++++++++------ 2 files changed, 84 insertions(+), 14 deletions(-) diff --git a/README.sh b/README.sh index 73ceebc..3ec2781 100755 --- a/README.sh +++ b/README.sh @@ -24,8 +24,67 @@ 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 up -d producer -sleep 5 -docker-compose stop producer -docker-compose logs producer +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 consumer + +sleep 10 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen + +docker-compose exec -T cli bash << 'EOF' +echo "Altering number of partitions from 3 to 7..." +# tag::altertopic[] +kafka-topics --bootstrap-server kafka:9092 --alter --topic test --partitions 7 +kafka-topics --bootstrap-server kafka:9092 --describe --topic test +# end::altertopic[] +EOF + +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen + +http post :8081/stop +http post :8081/start + +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen +sleep 1 +http :8081/seen + +docker-compose stop producer consumer diff --git a/docker-compose.yml b/docker-compose.yml index 10ad3a0..d715e66 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,13 +24,13 @@ services: depends_on: - zookeeper - setup: - image: juplo/toolbox - command: > - bash -c " - kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test - kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 - " + kafka-ui: + image: provectuslabs/kafka-ui:0.3.3 + ports: + - 8080:8080 + environment: + KAFKA_CLUSTERS_0_NAME: local + KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092 cli: image: juplo/toolbox @@ -39,9 +39,20 @@ services: producer: image: juplo/endless-producer:1.0-SNAPSHOT ports: - - 8080:8080 + - 8000:8080 environment: producer.bootstrap-server: kafka:9092 producer.client-id: producer producer.topic: test - producer.throttle-ms: 200 + producer.throttle-ms: 10 + + + consumer: + image: juplo/counting-consumer:1.0-SNAPSHOT + ports: + - 8081:8081 + environment: + consumer.bootstrap-server: kafka:9092 + consumer.client-id: my-group + consumer.client-id: consumer + consumer.topic: test -- 2.20.1