From: Kai Moritz Date: Sun, 1 Nov 2020 16:41:06 +0000 (+0100) Subject: Added an executable README.sh, that demonstrates the example X-Git-Tag: part-1~8 X-Git-Url: https://juplo.de/gitweb/?a=commitdiff_plain;h=b876bd8648a4f919cea5791e5e208a88d9e0cacd;p=demos%2Fkafka%2Foutbox Added an executable README.sh, that demonstrates the example --- diff --git a/README.sh b/README.sh new file mode 100755 index 0000000..6a4ef4c --- /dev/null +++ b/README.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +if [ "$1" = "cleanup" ] +then + docker-compose down -v + mvn clean + docker image rm juplo/jdbc:outbox + docker image rm juplo/outbox:polling + exit +fi + +if [[ + $(docker image ls -q juplo/jdbc:outbox) == "" || + $(docker image ls -q juplo/outbox:polling) == "" || + "$1" = "build" +]] +then + mvn package || exit +else + echo "Using image existing images:" + docker image ls juplo/jdbc:outbox + docker image ls juplo/outbox:polling +fi + +trap 'kill $(jobs -p)' EXIT + +docker-compose up -d zookeeper kafka + +while ! [[ $(zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]]; +do + echo "Waiting for kafka..."; + sleep 1; +done + +kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic outbox + + +docker-compose up -d jdbc outbox + +while ! [[ $(http :8080/actuator/health 2>/dev/null | jq -r .status) == "UP" ]]; +do + echo "Waiting for User-Service..."; + sleep 1; +done + + +kafkacat -C -b localhost:9092 -t outbox & + +echo peter | http :8080/users +echo franz | http :8080/users +echo beate | http :8080/users +http :8080/users +http DELETE :8080/users/franz +http :8080/users