From: Kai Moritz Date: Fri, 11 Jun 2021 11:17:02 +0000 (+0200) Subject: Iintial setup, that contains only the MVP of the transfer-service X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=21ca3a5d90c890a44101b1d8c76e446336899335;p=demos%2Fkafka%2Fdemos-kafka-payment-system-setup Iintial setup, that contains only the MVP of the transfer-service --- 21ca3a5d90c890a44101b1d8c76e446336899335 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c38fa4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +*.iml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..863a129 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "transfer"] + path = transfer + url = ../demos-kafka-payment-system-transfer diff --git a/README.sh b/README.sh new file mode 100755 index 0000000..67df46e --- /dev/null +++ b/README.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +if [ "$1" = "cleanup" ] +then + docker-compose down + mvn clean + exit +fi + +mvn package || exit 1 +if [ ! -e transfer/target/BUILD ] || [ "$(find transfer/target/classes/ -anewer transfer/target/BUILD | grep transfer/target/classes/de )" != "" ] +then + echo "Rebuilding Docker-Image..." + docker-compose rm -svf transfer + mvn -f transfer/pom.xml docker:build + touch transfer/target/BUILD +fi +if [ "$1" = "build" ]; then exit; fi + +docker-compose up -d zookeeper kafka + +while ! [[ $(docker-compose run --rm kafka zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]]; do echo "Waiting for kafka..."; sleep 1; done + +docker-compose run --rm kafka kafka-topics --zookeeper zookeeper:2181 --if-not-exists --create --replication-factor 1 --partitions 5 --topic transfers + +docker-compose up -d transfer + +docker-compose run --name transferlog --rm kafka kafka-console-consumer --bootstrap-server kafka:9093 --topic transfers & +while ! [[ $(http 0:8091/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for transfer..."; sleep 1; done + +echo '{"id":1,"payer":1,"payee":2, "amount":10}' | http -v :8091/transfers +http :8091/transfers/1 +http -v :8091/transfers id=2 payer=2 payee=1 amount=5 +http :8091/transfers/2 + +docker container stop transferlog diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..eb1c720 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3.2' +services: + zookeeper: + image: confluentinc/cp-zookeeper:6.2.0 + ports: + - "2181:2181" + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + + kafka: + image: confluentinc/cp-kafka:6.2.0 + ports: + - 9092:9092 + environment: + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:9093,OUTSIDE://localhost:9092 + KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + depends_on: + - zookeeper + + transfer: + image: juplo/payment-service-demo--transfer:1.0.0 + ports: + - "8091:8080" + environment: + juplo.transfer.bootstrap-servers: kafka:9093 + depends_on: + - zookeeper + - kafka diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a9885f8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + de.trion.kafka.payment + payment-system-setup + Payment System Example - Setup + 1.0.0 + pom + + + transfer + + + diff --git a/transfer b/transfer new file mode 160000 index 0000000..1534808 --- /dev/null +++ b/transfer @@ -0,0 +1 @@ +Subproject commit 1534808f4b16d6dae9bd0bc417852d1cc7d7191b