Test prüft ungültige und unbekannte Nachrichten
[demos/kafka/training] / README.sh
1 #!/bin/bash
2
3 IMAGE=juplo/endless-consumer:1.0-SNAPSHOT
4
5 if [ "$1" = "cleanup" ]
6 then
7   docker-compose down -v
8   mvn clean
9   exit
10 fi
11
12 docker-compose up -d zookeeper kafka cli
13
14 if [[
15   $(docker image ls -q $IMAGE) == "" ||
16   "$1" = "build"
17 ]]
18 then
19   mvn install || exit
20 else
21   echo "Using image existing images:"
22   docker image ls $IMAGE
23 fi
24
25 echo "Waiting for the Kafka-Cluster to become ready..."
26 docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1
27 docker-compose up setup
28 docker-compose up -d producer consumer
29 sleep 5
30 docker-compose exec -T cli bash << 'EOF'
31 echo "Writing poison pill into topic test..."
32 # tag::poisonpill[]
33 echo 'BOOM!' | kafkacat -P -b kafka:9092 -t test
34 # end::poisonpill[]
35 EOF
36 while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Consumer is still running..."; sleep 1; done
37 http -v :8081/actuator/health
38 echo "Restarting consumer"
39 http -v post :8081/start
40 while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer..."; sleep 1; done
41 while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Consumer is still running..."; sleep 1; done
42 http -v :8081/actuator/health
43 http -v post :8081/actuator/shutdown
44 docker-compose stop producer
45 docker-compose ps
46 docker-compose logs --tail=100 consumer