Iintial setup, that contains only the MVP of the transfer-service
authorKai Moritz <kai@juplo.de>
Fri, 11 Jun 2021 11:17:02 +0000 (13:17 +0200)
committerKai Moritz <kai@juplo.de>
Thu, 24 Jun 2021 19:04:06 +0000 (21:04 +0200)
.gitignore [new file with mode: 0644]
.gitmodules [new file with mode: 0644]
README.sh [new file with mode: 0755]
docker-compose.yml [new file with mode: 0644]
pom.xml [new file with mode: 0644]
transfer [new submodule]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..c38fa4e
--- /dev/null
@@ -0,0 +1,2 @@
+.idea
+*.iml
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..863a129
--- /dev/null
@@ -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 (executable)
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 (file)
index 0000000..eb1c720
--- /dev/null
@@ -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 (file)
index 0000000..a9885f8
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,15 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>de.trion.kafka.payment</groupId>
+  <artifactId>payment-system-setup</artifactId>
+  <name>Payment System Example - Setup</name>
+  <version>1.0.0</version>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>transfer</module>
+  </modules>
+
+</project>
diff --git a/transfer b/transfer
new file mode 160000 (submodule)
index 0000000..1534808
--- /dev/null
+++ b/transfer
@@ -0,0 +1 @@
+Subproject commit 1534808f4b16d6dae9bd0bc417852d1cc7d7191b