This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 0ad7f4f43c56 CAMEL-24014: Fix flaky JmsDurableTopicIT (#24615)
0ad7f4f43c56 is described below

commit 0ad7f4f43c56999b32bb1df3c312a3d30037e427
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sun Jul 12 09:32:45 2026 +0200

    CAMEL-24014: Fix flaky JmsDurableTopicIT (#24615)
    
    CAMEL-24014: Fix flaky JmsDurableTopicIT
    
    Wait for both route-1 and route-2 uptime before publishing to topic,
    using JmsTestHelper.waitForJmsConsumerRoutes() to prevent durable
    subscriber registration race.
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../camel/component/jms/integration/JmsDurableTopicIT.java   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDurableTopicIT.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDurableTopicIT.java
index dd5f22d9830a..e5164899a75a 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDurableTopicIT.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDurableTopicIT.java
@@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jms.AbstractPersistentJMSTest;
+import org.apache.camel.component.jms.JmsTestHelper;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.awaitility.Awaitility;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
@@ -32,6 +32,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 @Timeout(30)
 public class JmsDurableTopicIT extends AbstractPersistentJMSTest {
+
+    // topic subscriptions take a little longer to register than queue 
consumers, so keep the longer 200ms threshold
+    private static final long TOPIC_ROUTE_UPTIME_MILLIS = 200;
+
     private MockEndpoint mock;
     private MockEndpoint mock2;
 
@@ -43,7 +47,11 @@ public class JmsDurableTopicIT extends 
AbstractPersistentJMSTest {
         mock2 = getMockEndpoint("mock:result2");
         mock2.expectedBodiesReceived("Hello World");
 
-        Awaitility.await().until(() -> 
context.getRoute("route-2").getUptimeMillis() > 200);
+        // Wait for BOTH durable topic consumer routes to be ready before 
sending.
+        // The original code only waited for route-2, so route-1's subscriber 
could
+        // still be registering when the message was published, causing 
mock:result
+        // to miss the message intermittently.
+        JmsTestHelper.waitForJmsConsumerRoutes(context, 
TOPIC_ROUTE_UPTIME_MILLIS, "route-1", "route-2");
     }
 
     @Test

Reply via email to