From 732f0b041004ffd23c27cfe64f9d46dbf0a86089 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 29 Jun 2021 21:05:55 +0200 Subject: [PATCH] A transfer-service, that stores the state locally to speed up recovery --- README.sh | 18 ++++++++++++++ docker-compose.yml | 58 ++++++++++++++++++++++++++++++---------------- transfer | 2 +- 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/README.sh b/README.sh index 21ee7c8..b161ab5 100755 --- a/README.sh +++ b/README.sh @@ -26,18 +26,30 @@ docker-compose run --rm kafka kafka-topics --zookeeper zookeeper:2181 --if-not-e docker-compose up -d peter ute franz beate klaus 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 peter..."; sleep 1; done +while ! [[ $(http 0:8092/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for ute..."; sleep 1; done +while ! [[ $(http 0:8093/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for franz..."; sleep 1; done +while ! [[ $(http 0:8094/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for beate..."; sleep 1; done +while ! [[ $(http 0:8095/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for klaus..."; sleep 1; done +echo '{"id":1,"payer":1,"payee":2, "amount":10}' | http -v :8091/transfers +echo '{"id":1,"payer":1,"payee":2, "amount":10}' | http -v :8091/transfers +echo '{"id":1,"payer":1,"payee":2, "amount":10}' | http -v :8091/transfers echo '{"id":1,"payer":1,"payee":2, "amount":10}' | http -v :8091/transfers http --follow :8091/transfers/1 http -v :8091/transfers id=2 payer=2 payee=1 amount=5 http --follow :8091/transfers/2 http -v :8091/transfers id=12 payer=2 payee=1 amount=5 http -v :8091/transfers id=21 payer=2 payee=1 amount=5 +http -v :8091/transfers id=9 payer=2 payee=1 amount=5 http -v :8091/transfers id=7 payer=2 payee=1 amount=5 http -v :8091/transfers id=9 payer=2 payee=1 amount=5 +http -v :8091/transfers id=9 payer=2 payee=1 amount=5 +http -v :8091/transfers id=9 payer=2 payee=1 amount=5 http -v :8091/transfers id=13 payer=2 payee=1 amount=5 http -v :8091/transfers id=31 payer=2 payee=1 amount=5 +http -v :8091/transfers id=31 payer=2 payee=1 amount=5 http -v --follow :8091/transfers/12 http -v --follow :8091/transfers/21 http -v --follow :8091/transfers/7 @@ -46,7 +58,13 @@ http -v --follow :8091/transfers/13 http -v --follow :8091/transfers/31 docker-compose restart peter ute franz beate klaus + while ! [[ $(http 0:8091/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for peter..."; sleep 1; done +while ! [[ $(http 0:8092/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for ute..."; sleep 1; done +while ! [[ $(http 0:8093/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for franz..."; sleep 1; done +while ! [[ $(http 0:8094/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for beate..."; sleep 1; done +while ! [[ $(http 0:8095/actuator/health 2> /dev/null | jq -r .status ) =~ "UP" ]]; do echo "Waiting for klaus..."; sleep 1; done + http -v --follow :8091/transfers/1 http -v --follow :8091/transfers/2 http -v --follow :8091/transfers/12 diff --git a/docker-compose.yml b/docker-compose.yml index 1f7f5a4..2bcdfac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,81 +31,99 @@ services: --topic transfers peter: - image: juplo/payment-service-demo--transfer:2.0.0 - ports: - - 8091:8080 + image: juplo/payment-service-demo--transfer:2.1.0 environment: - juplo.transfer.bootstrap-servers: kafka:9093 + server.port: 8091 juplo.transfer.group-instance-id: peter + juplo.transfer.local-state-store-path: /var/lib/app/peter.bin + juplo.transfer.state-store-interval: 20 juplo.transfer.instance-id-uri-mapping.peter: http://localhost:8091 juplo.transfer.instance-id-uri-mapping.ute: http://localhost:8092 juplo.transfer.instance-id-uri-mapping.franz: http://localhost:8093 juplo.transfer.instance-id-uri-mapping.beate: http://localhost:8094 juplo.transfer.instance-id-uri-mapping.klaus: http://localhost:8095 + volumes: + - data:/var/lib/app + network_mode: host depends_on: - zookeeper - kafka ute: - image: juplo/payment-service-demo--transfer:2.0.0 - ports: - - 8092:8080 + image: juplo/payment-service-demo--transfer:2.1.0 environment: - juplo.transfer.bootstrap-servers: kafka:9093 + server.port: 8092 juplo.transfer.group-instance-id: ute + juplo.transfer.local-state-store-path: /var/lib/app/ute.bin + juplo.transfer.state-store-interval: 20 juplo.transfer.instance-id-uri-mapping.peter: http://localhost:8091 juplo.transfer.instance-id-uri-mapping.ute: http://localhost:8092 juplo.transfer.instance-id-uri-mapping.franz: http://localhost:8093 juplo.transfer.instance-id-uri-mapping.beate: http://localhost:8094 juplo.transfer.instance-id-uri-mapping.klaus: http://localhost:8095 + volumes: + - data:/var/lib/app + network_mode: host depends_on: - zookeeper - kafka franz: - image: juplo/payment-service-demo--transfer:2.0.0 - ports: - - 8093:8080 + image: juplo/payment-service-demo--transfer:2.1.0 environment: - juplo.transfer.bootstrap-servers: kafka:9093 + server.port: 8093 juplo.transfer.group-instance-id: franz + juplo.transfer.local-state-store-path: /var/lib/app/franz.bin + juplo.transfer.state-store-interval: 20 juplo.transfer.instance-id-uri-mapping.peter: http://localhost:8091 juplo.transfer.instance-id-uri-mapping.ute: http://localhost:8092 juplo.transfer.instance-id-uri-mapping.franz: http://localhost:8093 juplo.transfer.instance-id-uri-mapping.beate: http://localhost:8094 juplo.transfer.instance-id-uri-mapping.klaus: http://localhost:8095 + volumes: + - data:/var/lib/app + network_mode: host depends_on: - zookeeper - kafka beate: - image: juplo/payment-service-demo--transfer:2.0.0 - ports: - - 8094:8080 + image: juplo/payment-service-demo--transfer:2.1.0 environment: - juplo.transfer.bootstrap-servers: kafka:9093 + server.port: 8094 juplo.transfer.group-instance-id: beate + juplo.transfer.local-state-store-path: /var/lib/app/beate.bin + juplo.transfer.state-store-interval: 20 juplo.transfer.instance-id-uri-mapping.peter: http://localhost:8091 juplo.transfer.instance-id-uri-mapping.ute: http://localhost:8092 juplo.transfer.instance-id-uri-mapping.franz: http://localhost:8093 juplo.transfer.instance-id-uri-mapping.beate: http://localhost:8094 juplo.transfer.instance-id-uri-mapping.klaus: http://localhost:8095 + volumes: + - data:/var/lib/app + network_mode: host depends_on: - zookeeper - kafka klaus: - image: juplo/payment-service-demo--transfer:2.0.0 - ports: - - 8095:8080 + image: juplo/payment-service-demo--transfer:2.1.0 environment: - juplo.transfer.bootstrap-servers: kafka:9093 + server.port: 8095 juplo.transfer.group-instance-id: klaus + juplo.transfer.local-state-store-path: /var/lib/app/klaus.bin + juplo.transfer.state-store-interval: 20 juplo.transfer.instance-id-uri-mapping.peter: http://localhost:8091 juplo.transfer.instance-id-uri-mapping.ute: http://localhost:8092 juplo.transfer.instance-id-uri-mapping.franz: http://localhost:8093 juplo.transfer.instance-id-uri-mapping.beate: http://localhost:8094 juplo.transfer.instance-id-uri-mapping.klaus: http://localhost:8095 + volumes: + - data:/var/lib/app + network_mode: host depends_on: - zookeeper - kafka + +volumes: + data: diff --git a/transfer b/transfer index 5662a3f..ab53b6c 160000 --- a/transfer +++ b/transfer @@ -1 +1 @@ -Subproject commit 5662a3f4f6868e3ae474825e977e49bddddd4043 +Subproject commit ab53b6ca43b3f0ad934837be1931af8f428b5221 -- 2.20.1