3 IMAGE=juplo/rest-producer:1.0-SNAPSHOT
5 if [ "$1" = "cleanup" ]
7 docker-compose down -v --remove-orphans
12 docker-compose up -d kafka-1 kafka-2 kafka-3 cli
13 docker-compose rm -svf producer producer-0 producer-1
16 $(docker image ls -q $IMAGE) == "" ||
20 mvn clean install || exit
22 echo "Using image existing images:"
23 docker image ls $IMAGE
26 docker-compose up setup
27 docker-compose up -d producer-0 producer-1
28 while ! [[ $(http 0:8000/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-0..."; sleep 1; done
29 while ! [[ $(http 0:8001/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-1..."; sleep 1; done
30 docker-compose up -d consumer
33 echo -n Nachricht 1 an Producer 0 | http -v :8000/foo
34 echo -n Nachricht 1 an Producer 1 | http -v :8001/foo
36 echo -n Nachricht 2 an Producer 0 | http -v :8000/bar
37 echo -n Nachricht 2 an Producer 1 | http -v :8001/bar
39 docker-compose logs consumer
41 docker-compose exec -T cli bash << 'EOF'
42 echo "Altering number of partitions from 3 to 7..."
43 kafka-topics --bootstrap-server kafka:9092 --describe --topic test
44 # tag::repartitioning[]
45 kafka-topics --bootstrap-server kafka:9092 --alter --topic test --partitions 7
46 # end::repartitioning[]
47 kafka-topics --bootstrap-server kafka:9092 --describe --topic test
50 docker-compose restart producer-0 producer-1
51 while ! [[ $(http 0:8000/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-0..."; sleep 1; done
52 while ! [[ $(http 0:8001/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-1..."; sleep 1; done
54 echo -n Nachricht 3 an Producer 0 | http -v :8000/foo
55 echo -n Nachricht 3 an Producer 1 | http -v :8001/foo
56 echo -n Nachricht 4 an Producer 0 | http -v :8000/bar
57 echo -n Nachricht 4 an Producer 1 | http -v :8001/bar
59 docker-compose logs consumer
62 kafkacat -b :9092 -t test -o 0 -p0 -f'p=%p|o=%o|k=%k|v=%s\n' -qe
63 kafkacat -b :9092 -t test -o 0 -p1 -f'p=%p|o=%o|k=%k|v=%s\n' -qe