fi
docker-compose up -d kafka-1 kafka-2 kafka-3 cli
-docker-compose rm -svf producer
+docker-compose rm -svf producer producer-0 producer-1
if [[
$(docker image ls -q $IMAGE) == "" ||
fi
docker-compose up setup
-docker-compose ps
-docker-compose up -d producer
-
-while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer..."; sleep 1; done
-
-# tag::success[]
-echo -n 'Hallo Welt!' | http -v :8080/foo
-# end::success[]
-
-# tag::failure[]
-dd if=/dev/zero bs=1024 count=1024 | http -v :8080/bar
-# end::failure[]
-
-# tag::timeout[]
-docker-compose stop kafka-1 kafka-2 kafka-3
-echo -n 'Hallo again...' | http -v --timeout 30 :8080/foo
-# end::timeout[]
+docker-compose up -d producer-0 producer-1
+while ! [[ $(http 0:8000/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-0..."; sleep 1; done
+while ! [[ $(http 0:8001/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-1..."; sleep 1; done
+docker-compose up -d consumer
+
+echo -n Nachricht 1 an Producer 0 | http -v :8000/foo
+echo -n Nachricht 1 an Producer 1 | http -v :8001/foo
+echo -n Nachricht 2 an Producer 0 | http -v :8000/bar
+echo -n Nachricht 2 an Producer 1 | http -v :8001/bar
+
+docker-compose logs consumer
+
+docker-compose exec -T cli bash << 'EOF'
+echo "Altering number of partitions from 3 to 7..."
+kafka-topics --bootstrap-server kafka:9092 --describe --topic test
+kafka-topics --bootstrap-server kafka:9092 --describe --topic test
+kafka-topics --bootstrap-server kafka:9092 --alter --topic test --partitions 7
+kafka-topics --bootstrap-server kafka:9092 --describe --topic test
+EOF
+
+docker-compose restart producer-0 producer-1
+while ! [[ $(http 0:8000/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-0..."; sleep 1; done
+while ! [[ $(http 0:8001/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer-1..."; sleep 1; done
+
+echo -n Nachricht 3 an Producer 0 | http -v :8000/foo
+echo -n Nachricht 3 an Producer 1 | http -v :8001/foo
+echo -n Nachricht 4 an Producer 0 | http -v :8000/bar
+echo -n Nachricht 4 an Producer 1 | http -v :8001/bar
+
+docker-compose logs consumer
+
+kafkacat -b :9092 -t test -o 0 -p0 -f'p=%p|o=%o|k=%k|v=%s\n' -qe
+kafkacat -b :9092 -t test -o 0 -p1 -f'p=%p|o=%o|k=%k|v=%s\n' -qe
producer.client-id: producer
producer.topic: test
+ producer-0:
+ image: juplo/rest-producer:1.0-SNAPSHOT
+ ports:
+ - 8000:8080
+ environment:
+ server.port: 8080
+ producer.bootstrap-server: kafka:9092
+ producer.client-id: producer-0
+ producer.topic: test
+ producer.partition: 0
+
+ producer-1:
+ image: juplo/rest-producer:1.0-SNAPSHOT
+ ports:
+ - 8001:8080
+ environment:
+ server.port: 8080
+ producer.bootstrap-server: kafka:9092
+ producer.client-id: producer-1
+ producer.topic: test
+ producer.partition: 1
+
consumer:
image: juplo/simple-consumer:1.0-SNAPSHOT
command: kafka:9092 test my-group consumer