From 0dde95c9d9e31422913ce14135c374b7dc999364 Mon Sep 17 00:00:00 2001 From: croway Date: Fri, 4 Sep 2026 10:23:13 +0200 Subject: [PATCH] Fix saga example: Artemis autoconfig, run-local pid tracking, unauthenticated broker image Under Spring Boot 4, Artemis autoconfiguration moved to spring-boot-starter-artemis, which the saga poms didn't declare (only raw artemis-jakarta-client/pooled-jms), so spring.artemis.* properties were silently ignored and all 4 services crashed with "connectionFactory must be specified". Add spring-boot-starter-artemis. run-local.sh never redirected output or captured PIDs into the .pid/.log files that stop-local.sh expects, breaking the stop script. Also, mvn spring-boot:run always forks a child JVM, so the captured PID was the mvn wrapper, not the actual process; stop-local.sh now kills the forked child(ren) too. Replace the Red Hat registry AMQ broker image (registry.redhat.io/amq7/amq-broker-rhel8, requires authenticated registry credentials) with the unauthenticated apache/artemis image in both the local docker-compose file and the OpenShift resources, since Artemis supports OPENWIRE (and the other protocols the saga services need) out of the box. Verified end-to-end locally: broker/coordinator start, all 4 services boot without the connectionFactory crash, and a full saga run completes (train reserved, flight booked, both payments processed over JMS/OPENWIRE). Verified stop-local.sh now actually terminates the JVM processes and containers. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01EbjZemqMg395XFGDRekLBM --- saga/local-resources/compose.yaml | 7 +++---- saga/ocp-resources/amq-broker-ephemeral.yaml | 8 +++----- saga/ocp-resources/amq-broker.yaml | 12 ++++-------- saga/pom.xml | 4 ++++ saga/run-local.sh | 12 ++++++++---- saga/stop-local.sh | 17 +++++++++++++---- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/saga/local-resources/compose.yaml b/saga/local-resources/compose.yaml index 591f16175..23b206c36 100644 --- a/saga/local-resources/compose.yaml +++ b/saga/local-resources/compose.yaml @@ -3,11 +3,10 @@ services: image: "quay.io/jbosstm/lra-coordinator:latest" network_mode: "host" amq-broker: - image: "registry.redhat.io/amq7/amq-broker-rhel8:7.12" + image: "apache/artemis:latest-alpine" environment: - - AMQ_USER=admin - - AMQ_PASSWORD=admin - - AMQ_REQUIRE_LOGIN=true + - ARTEMIS_USER=admin + - ARTEMIS_PASSWORD=admin ports: - "8161:8161" - "61616:61616" diff --git a/saga/ocp-resources/amq-broker-ephemeral.yaml b/saga/ocp-resources/amq-broker-ephemeral.yaml index 701d20fc5..92430ac0b 100644 --- a/saga/ocp-resources/amq-broker-ephemeral.yaml +++ b/saga/ocp-resources/amq-broker-ephemeral.yaml @@ -35,7 +35,7 @@ items: tags: - from: kind: DockerImage - name: registry.redhat.io/amq7/amq-broker-rhel8:7.12 + name: apache/artemis:latest-alpine generation: 0 name: "latest" referencePolicy: @@ -67,12 +67,10 @@ items: - imagePullPolicy: IfNotPresent image: "amq-broker:latest" env: - - name: AMQ_USER + - name: ARTEMIS_USER value: admin - - name: AMQ_PASSWORD + - name: ARTEMIS_PASSWORD value: admin - - name: AMQ_REQUIRE_LOGIN - value: "true" livenessProbe: httpGet: path: / diff --git a/saga/ocp-resources/amq-broker.yaml b/saga/ocp-resources/amq-broker.yaml index 348c0e875..b02695823 100644 --- a/saga/ocp-resources/amq-broker.yaml +++ b/saga/ocp-resources/amq-broker.yaml @@ -48,7 +48,7 @@ items: tags: - from: kind: DockerImage - name: registry.redhat.io/amq7/amq-broker-rhel8:7.12 + name: apache/artemis:latest-alpine generation: 0 name: "latest" referencePolicy: @@ -80,14 +80,10 @@ items: - imagePullPolicy: IfNotPresent image: "amq-broker:latest" env: - - name: AMQ_USER + - name: ARTEMIS_USER value: admin - - name: AMQ_PASSWORD + - name: ARTEMIS_PASSWORD value: admin - - name: AMQ_REQUIRE_LOGIN - value: "true" - - name: AMQ_DATA_DIR - value: /data livenessProbe: httpGet: path: / @@ -107,7 +103,7 @@ items: scheme: HTTP initialDelaySeconds: 10 volumeMounts: - - mountPath: /data + - mountPath: /var/lib/artemis-instance name: amq-broker-data volumes: - name: amq-broker-data diff --git a/saga/pom.xml b/saga/pom.xml index 0306dba21..50ae47c30 100644 --- a/saga/pom.xml +++ b/saga/pom.xml @@ -106,6 +106,10 @@ + + org.springframework.boot + spring-boot-starter-artemis + org.apache.activemq artemis-jakarta-client diff --git a/saga/run-local.sh b/saga/run-local.sh index 8763a80d5..1640161e8 100755 --- a/saga/run-local.sh +++ b/saga/run-local.sh @@ -7,15 +7,19 @@ echo compiling project mvn clean package echo running payment service -mvn -f saga-payment-service/ spring-boot:run & +mvn -f saga-payment-service/ spring-boot:run > payment.log 2>&1 & +echo $! > payment.pid echo running flight service -mvn -f saga-flight-service/ spring-boot:run & +mvn -f saga-flight-service/ spring-boot:run > flight.log 2>&1 & +echo $! > flight.pid echo running train service -mvn -f saga-train-service/ spring-boot:run & +mvn -f saga-train-service/ spring-boot:run > train.log 2>&1 & +echo $! > train.pid echo running saga application -mvn -f saga-app/ spring-boot:run & +mvn -f saga-app/ spring-boot:run > app.log 2>&1 & +echo $! > app.pid wait diff --git a/saga/stop-local.sh b/saga/stop-local.sh index 7769a77f4..6006cc1ab 100755 --- a/saga/stop-local.sh +++ b/saga/stop-local.sh @@ -1,16 +1,25 @@ #!/bin/bash +# mvn spring-boot:run always forks a child JVM, so the pid files hold the +# mvn process id, not the actual Spring Boot process; kill the forked +# child(ren) first, then the mvn process itself. +kill_mvn_and_children() { + local pid="$1" + pkill -9 -P "$pid" 2>/dev/null + kill -9 "$pid" 2>/dev/null +} + echo stopping saga application -kill -9 $(cat app.pid) && rm app.pid +kill_mvn_and_children $(cat app.pid) && rm app.pid echo stopping flight service -kill -9 $(cat flight.pid) && rm flight.pid +kill_mvn_and_children $(cat flight.pid) && rm flight.pid echo stopping train service -kill -9 $(cat train.pid) && rm train.pid +kill_mvn_and_children $(cat train.pid) && rm train.pid echo stopping payment service -kill -9 $(cat payment.pid) && rm payment.pid +kill_mvn_and_children $(cat payment.pid) && rm payment.pid echo stopping amq broker and lra-coordinator docker compose -f local-resources/compose.yaml stop