You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/11 12:46:49 UTC

[camel] 01/01: camel-sjms - Run test fast that was waiting for a latch with a wrong count

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

davsclaus pushed a commit to branch sjms-fast
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9b8b4a9566fe8d81190d5718bac0f6ea3f81d81a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 11 14:46:31 2023 +0200

    camel-sjms - Run test fast that was waiting for a latch with a wrong count
---
 .../camel/component/sjms/tx/TransactedConsumerSupport.java  | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedConsumerSupport.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedConsumerSupport.java
index 09c1980f39e..8c2c312df71 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedConsumerSupport.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedConsumerSupport.java
@@ -51,7 +51,7 @@ public abstract class TransactedConsumerSupport extends CamelTestSupport {
         // unit all the messages have been processed. It is also
         // set to time out on the await. Our values are multiplied
         // by the number of routes we have.
-        CountDownLatch latch = new CountDownLatch((totalRedeliverdFalse * routeCount) + (totalRedeliveredTrue * routeCount));
+        CountDownLatch latch = new CountDownLatch((totalRedeliverdFalse * routeCount));
 
         for (int i = 1; i <= routeCount; i++) {
             // We add a route here so we can pass our latch into it.
@@ -68,13 +68,16 @@ public abstract class TransactedConsumerSupport extends CamelTestSupport {
         // Send only 10 messages
         for (int i = 1; i <= messageCount; i++) {
             String message = "Hello World " + i;
-            template.sendBody("direct:start", message);
+            template.sendBody("direct:start?block=false", message);
             log.trace("Sending message: {}", message);
         }
 
-        // Await on our countdown for 30 seconds at most then move on
-        latch.await(30, TimeUnit.SECONDS);
-        MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
+        // Await on our countdown for 20 seconds at most then move on
+        log.info("Waiting for latch to count down from: {}", latch.getCount());
+        boolean zero = latch.await(20, TimeUnit.SECONDS);
+        log.info("Latch wait done: {} with count: {}", zero, latch.getCount());
+
+        MockEndpoint.assertIsSatisfied(context);
     }
 
     @Override