README.sh zeigt die Auswirkung einer geƤnderten Partitions-Anzahl
authorKai Moritz <kai@juplo.de>
Sat, 2 Apr 2022 08:42:05 +0000 (10:42 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 2 Apr 2022 09:04:46 +0000 (11:04 +0200)
README.sh
docker-compose.yml

index c57a29b..9ed7d6f 100755 (executable)
--- a/README.sh
+++ b/README.sh
@@ -24,8 +24,20 @@ 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 consumer
+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 consumer
+
+docker-compose up -d producer
 sleep 10
 http :8081/seen
 sleep 1
@@ -34,8 +46,42 @@ 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
+
+docker-compose restart producer
+sleep 10
+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
+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
-docker-compose logs consumer
index 8c995e7..d715e66 100644 (file)
@@ -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,12 +39,12 @@ 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: