This is an automated email from the ASF dual-hosted git repository. apupier pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit eb14d92b195c420ad52c9c4fa058e899fcdee95b Author: Aurélien Pupier <[email protected]> AuthorDate: Tue Oct 6 14:39:53 2026 +0200 CAMEL-25341: scope Camel URIs per IT class to prevent cross-test interference All LRA*IT classes share the same singleton Narayana LRA coordinator container. Each class gets its own Camel context on a distinct port, but the compensation/completion callback URLs registered with the coordinator encode the Camel endpoint URI as a query parameter (URL_COMPENSATION_KEY / URL_COMPLETION_KEY). Before this change several generic URI names were reused across classes: direct:saga — LRACreditIT, LRAManualIT, LRATimeoutIT direct:compensate — LRAManualIT, LRAFailuresIT direct:complete — LRAManualIT, LRAFailuresIT direct:saga-compensate — LRAFailuresIT (unique, but named generically) direct:saga-complete — LRAFailuresIT (unique, but named generically) direct:workflow — LRAOptionsIT (unique, but named generically) While each name resolves to a different host:port at the coordinator level, duplicate URI strings in the LRASagaService allowlist (shared across all tests in the same JVM run) can cause the wrong compensation or completion handler to be invoked if the coordinator happens to call back on the wrong context. Rename every direct: URI to carry a class-scoped prefix: LRAManualIT → direct:manual-* LRATimeoutIT → direct:timeout-* LRAFailuresIT → direct:failures-* LRACreditIT → direct:credit-* LRAOptionsIT → direct:options-* Co-authored-by: IBM Bob 2.2.1 Signed-off-by: Aurélien Pupier <[email protected]> --- .../org/apache/camel/service/lra/LRACreditIT.java | 24 +++++++++++----------- .../apache/camel/service/lra/LRAFailuresIT.java | 16 +++++++-------- .../org/apache/camel/service/lra/LRAManualIT.java | 16 +++++++-------- .../org/apache/camel/service/lra/LRAOptionsIT.java | 10 ++++----- .../org/apache/camel/service/lra/LRATimeoutIT.java | 8 ++++---- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java index 8cf84e7185b8..c38937d9e915 100644 --- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java +++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java @@ -69,7 +69,7 @@ public class LRACreditIT extends AbstractLRATestSupport { private void buy(int amount, boolean failAtTheEnd, boolean shouldFail) { try { context.createFluentProducerTemplate() - .to("direct:saga") + .to("direct:credit-saga") .withHeader("amount", amount) .withHeader("fail", failAtTheEnd) .request(); @@ -95,48 +95,48 @@ public class LRACreditIT extends AbstractLRATestSupport { creditService = new CreditService(100); - from("direct:saga") + from("direct:credit-saga") .saga().propagation(SagaPropagation.REQUIRES_NEW) .log("Creating a new order") - .to("direct:newOrder") + .to("direct:credit-newOrder") .log("Taking the credit") - .to("direct:reserveCredit") + .to("direct:credit-reserveCredit") .log("Finalizing") - .to("direct:finalize") + .to("direct:credit-finalize") .log("Done!"); // Order service - from("direct:newOrder") + from("direct:credit-newOrder") .saga() .propagation(SagaPropagation.MANDATORY) - .compensation("direct:cancelOrder") + .compensation("direct:credit-cancelOrder") .transform().header(Exchange.SAGA_LONG_RUNNING_ACTION) .bean(orderManagerService, "newOrder") .log("Order ${body} created"); - from("direct:cancelOrder") + from("direct:credit-cancelOrder") .transform().header(Exchange.SAGA_LONG_RUNNING_ACTION) .bean(orderManagerService, "cancelOrder") .log("Order ${body} cancelled"); // Credit service - from("direct:reserveCredit") + from("direct:credit-reserveCredit") .saga() .propagation(SagaPropagation.MANDATORY) - .compensation("direct:refundCredit") + .compensation("direct:credit-refundCredit") .transform().header(Exchange.SAGA_LONG_RUNNING_ACTION) .bean(creditService, "reserveCredit") .log("Credit ${header.amount} reserved in action ${body}"); - from("direct:refundCredit") + from("direct:credit-refundCredit") .transform().header(Exchange.SAGA_LONG_RUNNING_ACTION) .bean(creditService, "refundCredit") .log("Credit for action ${body} refunded"); // Final actions - from("direct:finalize") + from("direct:credit-finalize") .saga().propagation(SagaPropagation.NOT_SUPPORTED) .choice() .when(header("fail").isEqualTo(true)) diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java index a6f70775a99a..9cbe356f832e 100644 --- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java +++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java @@ -38,7 +38,7 @@ public class LRAFailuresIT extends AbstractLRATestSupport { MockEndpoint compensate = getMockEndpoint("mock:compensate"); compensate.expectedMessageCount(1); - TestSupport.sendBody(template, "direct:saga-compensate", "hello"); + TestSupport.sendBody(template, "direct:failures-saga-compensate", "hello"); await().atMost(60, TimeUnit.SECONDS) .until(() -> compensate.getReceivedCounter() >= 1); @@ -55,7 +55,7 @@ public class LRAFailuresIT extends AbstractLRATestSupport { MockEndpoint end = getMockEndpoint("mock:end"); end.expectedBodiesReceived("hello"); - TestSupport.sendBody(template, "direct:saga-complete", "hello"); + TestSupport.sendBody(template, "direct:failures-saga-complete", "hello"); // The Narayana LRA coordinator retries failed completion callbacks via // its periodic recovery manager (default: every 120s). Rather than wait @@ -81,19 +81,19 @@ public class LRAFailuresIT extends AbstractLRATestSupport { @Override public void configure() { - from("direct:saga-compensate") + from("direct:failures-saga-compensate") .saga() - .compensation("direct:compensate") + .compensation("direct:failures-compensate") .process(x -> { throw new RuntimeCamelException("fail"); }); - from("direct:saga-complete") + from("direct:failures-saga-complete") .saga() - .completion("direct:complete") + .completion("direct:failures-complete") .to("mock:end"); - from("direct:compensate") + from("direct:failures-compensate") .process(x -> { int current = maxFailures.decrementAndGet(); if (current >= 0) { @@ -102,7 +102,7 @@ public class LRAFailuresIT extends AbstractLRATestSupport { }) .to("mock:compensate"); - from("direct:complete") + from("direct:failures-complete") .process(x -> { int current = maxFailures.decrementAndGet(); if (current >= 0) { diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java index 127d7c2e7e36..7ea7c55c7ba5 100644 --- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java +++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java @@ -34,7 +34,7 @@ public class LRAManualIT extends AbstractLRATestSupport { completeEndpoint.expectedMessageCount(1); completeEndpoint.expectedHeaderReceived("id", "1"); - TestSupport.sendBody(template, "direct:saga", "hello", Collections.singletonMap("myid", "1")); + TestSupport.sendBody(template, "direct:manual-saga", "hello", Collections.singletonMap("myid", "1")); completeEndpoint.assertIsSatisfied(); } @@ -44,7 +44,7 @@ public class LRAManualIT extends AbstractLRATestSupport { MockEndpoint compensateEndpoint = getMockEndpoint("mock:compensate"); compensateEndpoint.expectedMessageCount(1); - TestSupport.sendBody(template, "direct:saga", "fail"); + TestSupport.sendBody(template, "direct:manual-saga", "fail"); compensateEndpoint.assertIsSatisfied(); } @@ -54,7 +54,7 @@ public class LRAManualIT extends AbstractLRATestSupport { MockEndpoint compensateEndpoint = getMockEndpoint("mock:compensate"); compensateEndpoint.expectedMessageCount(1); - TestSupport.sendBody(template, "direct:saga", "timeout"); + TestSupport.sendBody(template, "direct:manual-saga", "timeout"); compensateEndpoint.assertIsSatisfied(); } @@ -65,13 +65,13 @@ public class LRAManualIT extends AbstractLRATestSupport { @Override public void configure() { - from("direct:saga") + from("direct:manual-saga") .saga() .completionMode(SagaCompletionMode.MANUAL) .timeout(1, TimeUnit.SECONDS) .option("id", header("myid")) - .completion("direct:complete") - .compensation("direct:compensate") + .completion("direct:manual-complete") + .compensation("direct:manual-compensate") .to("mock:endpoint") .choice() .when(body().isEqualTo("fail")) @@ -80,11 +80,11 @@ public class LRAManualIT extends AbstractLRATestSupport { .to("saga:complete") .end(); - from("direct:complete") + from("direct:manual-complete") .log("YES!") .to("mock:complete"); - from("direct:compensate") + from("direct:manual-compensate") .log("NO :(") .to("mock:compensate"); diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java index 813f0bea4806..a11b1eb9df0b 100644 --- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java +++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java @@ -35,7 +35,7 @@ public class LRAOptionsIT extends AbstractLRATestSupport { complete.expectedHeaderReceived("name", "Nicola"); complete.expectedMessagesMatches(ex -> ex.getIn().getHeader(Exchange.SAGA_LONG_RUNNING_ACTION) != null); - template.sendBodyAndHeader("direct:workflow", "Hello", "myname", "Nicola"); + template.sendBodyAndHeader("direct:options-workflow", "Hello", "myname", "Nicola"); complete.assertIsSatisfied(); } @@ -50,7 +50,7 @@ public class LRAOptionsIT extends AbstractLRATestSupport { compensate.expectedMessagesMatches(ex -> ex.getIn().getHeader(Exchange.SAGA_LONG_RUNNING_ACTION) != null); assertThrows(Exception.class, - () -> template.sendBodyAndHeader("direct:workflow", "compensate", "myname", "Nicola")); + () -> template.sendBodyAndHeader("direct:options-workflow", "compensate", "myname", "Nicola")); compensate.assertIsSatisfied(); } @@ -58,7 +58,7 @@ public class LRAOptionsIT extends AbstractLRATestSupport { @Test public void testRouteDoesNotHangOnOptionError() { assertThrows(RuntimeCamelException.class, - () -> template.sendBody("direct:wrong-expression", "Hello")); + () -> template.sendBody("direct:options-wrong-expression", "Hello")); } @Override @@ -68,7 +68,7 @@ public class LRAOptionsIT extends AbstractLRATestSupport { @Override public void configure() { - from("direct:workflow") + from("direct:options-workflow") .saga() .option("id", constant("myheader")) .option("name", header("myname")) @@ -84,7 +84,7 @@ public class LRAOptionsIT extends AbstractLRATestSupport { .setHeader("name", constant("TryToOverride")) .to("mock:endpoint"); - from("direct:wrong-expression") + from("direct:options-wrong-expression") .saga() .option("id", simple("${body.pippo.pluto}")) .to("log:info"); diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java index 92e689e67bae..1c7df6a7a671 100644 --- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java +++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java @@ -35,7 +35,7 @@ public class LRATimeoutIT extends AbstractLRATestSupport { MockEndpoint end = getMockEndpoint("mock:end"); end.expectedMessageCount(1); - template.sendBody("direct:saga", "Hello"); + template.sendBody("direct:timeout-saga", "Hello"); end.assertIsSatisfied(); compensate.assertIsSatisfied(); @@ -55,7 +55,7 @@ public class LRATimeoutIT extends AbstractLRATestSupport { MockEndpoint end = getMockEndpoint("mock:end"); end.expectedMessageCount(1); - template.sendBody("direct:saga-auto", "Hello"); + template.sendBody("direct:timeout-saga-auto", "Hello"); end.assertIsSatisfied(); complete.assertIsSatisfied(); @@ -69,7 +69,7 @@ public class LRATimeoutIT extends AbstractLRATestSupport { @Override public void configure() { - from("direct:saga") + from("direct:timeout-saga") .saga() .timeout(100, TimeUnit.MILLISECONDS) .option("id", constant("myid")) @@ -77,7 +77,7 @@ public class LRATimeoutIT extends AbstractLRATestSupport { .compensation("mock:compensate") .to("mock:end"); - from("direct:saga-auto") + from("direct:timeout-saga-auto") .saga() .timeout(350, TimeUnit.MILLISECONDS) .option("id", constant("myid"))
