Demonstration in README.sh gepimped
authorKai Moritz <kai@juplo.de>
Sat, 13 Aug 2022 10:37:27 +0000 (12:37 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 13 Aug 2022 10:37:27 +0000 (12:37 +0200)
README.sh
docker-compose.yml

index fe237dc..2a1e5d8 100755 (executable)
--- a/README.sh
+++ b/README.sh
@@ -25,22 +25,44 @@ 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
-docker-compose up consumer &
-while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer..."; sleep 1; done
+docker-compose up -d
+
+while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-1..."; sleep 1; done
+while ! [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-2..."; sleep 1; done
+while ! [[ $(http 0:8083/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-3..."; sleep 1; done
+while ! [[ $(http 0:8084/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-4..."; sleep 1; done
+while ! [[ $(http 0:8085/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-5..."; sleep 1; done
+
 sleep 5
+
 docker-compose exec -T cli bash << 'EOF'
 echo "Writing poison pill into topic test..."
 # tag::poisonpill[]
 echo 'BOOM!' | kafkacat -P -b kafka:9092 -t test
 # end::poisonpill[]
 EOF
-while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Consumer is still running..."; sleep 1; done
+
+while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-1 is still running..."; sleep 1; done
+while [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-2 is still running..."; sleep 1; done
+while [[ $(http 0:8083/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-3 is still running..."; sleep 1; done
+while [[ $(http 0:8084/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-4 is still running..."; sleep 1; done
+while [[ $(http 0:8085/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-5 is still running..."; sleep 1; done
+
 http -v :8081/actuator/health
-echo "Restarting consumer"
+echo "Restarting consumer-1"
 http -v post :8081/start
-while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer..."; sleep 1; done
-while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Consumer is still running..."; sleep 1; done
+
+echo "Waiting for consumer-1 to come up"
+while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-1..."; sleep 1; done
+http -v :8081/actuator/health
+
+echo "Waiting for consumer-1 to crash"
+while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-1 is still running..."; sleep 1; done
 http -v :8081/actuator/health
-http -v post :8081/actuator/shutdown
+
 docker-compose stop producer
+docker-compose logs --tail=10 consumer-1
+docker-compose logs --tail=10 consumer-2
+docker-compose logs --tail=10 consumer-3
+docker-compose logs --tail=10 consumer-4
+docker-compose logs --tail=10 consumer-5
index 81b98ac..d36e851 100644 (file)
@@ -48,13 +48,47 @@ services:
       producer.throttle-ms: 200
 
 
-  consumer:
+  consumer-1:
     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
+      consumer.client-id: consumer-1
+
+  consumer-2:
+    image: juplo/endless-consumer:1.0-SNAPSHOT
+    ports:
+      - 8082:8080
+    environment:
+      server.port: 8080
+      consumer.bootstrap-server: kafka:9092
+      consumer.client-id: consumer-2
+
+  consumer-3:
+    image: juplo/endless-consumer:1.0-SNAPSHOT
+    ports:
+      - 8083:8080
+    environment:
+      server.port: 8080
+      consumer.bootstrap-server: kafka:9092
+      consumer.client-id: consumer-3
+
+  consumer-4:
+    image: juplo/endless-consumer:1.0-SNAPSHOT
+    ports:
+      - 8084:8080
+    environment:
+      server.port: 8080
+      consumer.bootstrap-server: kafka:9092
+      consumer.client-id: consumer-4
+
+  consumer-5:
+    image: juplo/endless-consumer:1.0-SNAPSHOT
+    ports:
+      - 8085:8080
+    environment:
+      server.port: 8080
+      consumer.bootstrap-server: kafka:9092
+      consumer.client-id: consumer-5