This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git
The following commit(s) were added to refs/heads/main by this push: new 840d59c CAMEL-21958: camel-core: Java DSL. Fix endChoice() to reuse end() and scope to current/nearest choice. 840d59c is described below commit 840d59c0b8ce6034b719b581ca8ba6614e9c2308 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Apr 16 07:14:00 2025 +0200 CAMEL-21958: camel-core: Java DSL. Fix endChoice() to reuse end() and scope to current/nearest choice. --- .../apache/camel/example/saga/PaymentRoute.java | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/saga/saga-payment-service/src/main/java/org/apache/camel/example/saga/PaymentRoute.java b/saga/saga-payment-service/src/main/java/org/apache/camel/example/saga/PaymentRoute.java index c73ad56..10e1576 100644 --- a/saga/saga-payment-service/src/main/java/org/apache/camel/example/saga/PaymentRoute.java +++ b/saga/saga-payment-service/src/main/java/org/apache/camel/example/saga/PaymentRoute.java @@ -26,26 +26,23 @@ public class PaymentRoute extends RouteBuilder { @Override public void configure() throws Exception { - - from("jms:queue:{{example.services.payment}}") - .routeId("payment-service") - .saga() - .propagation(SagaPropagation.MANDATORY) - .option("id", header("id")) - .compensation("direct:cancelPayment") - .log("Paying ${header.payFor} for order #${header.id}") - .setBody(header("JMSCorrelationID")) - .choice() - .when(x -> Math.random() >= 0.85) - .log("Payment ${header.payFor} for saga #${header.id} fails!") - .throwException(new RuntimeException("Random failure during payment")) - .endChoice() - .end() - .log("Payment ${header.payFor} done for order #${header.id} with payment transaction ${body}") - .end(); + from("jms:queue:{{example.services.payment}}") + .routeId("payment-service") + .saga() + .propagation(SagaPropagation.MANDATORY) + .option("id", header("id")) + .compensation("direct:cancelPayment") + .log("Paying ${header.payFor} for order #${header.id}") + .setBody(header("JMSCorrelationID")) + .choice() + .when(x -> Math.random() >= 0.85) + .log("Payment ${header.payFor} for saga #${header.id} fails!") + .throwException(new RuntimeException("Random failure during payment")) + .end() + .log("Payment ${header.payFor} done for order #${header.id} with payment transaction ${body}"); from("direct:cancelPayment") - .routeId("payment-cancel") - .log("Payment for order #${header.id} has been cancelled"); + .routeId("payment-cancel") + .log("Payment for order #${header.id} has been cancelled"); } }