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/07/24 08:01:31 UTC

[camel] branch flaky-jms created (now fc79d23072b)

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

davsclaus pushed a change to branch flaky-jms
in repository https://gitbox.apache.org/repos/asf/camel.git


      at fc79d23072b camel-jms - Flaky test due to session gets closed which should be ignored.

This branch includes the following new commits:

     new fc79d23072b camel-jms - Flaky test due to session gets closed which should be ignored.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 01/01: camel-jms - Flaky test due to session gets closed which should be ignored.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fc79d23072be43975c121dc02e25d87a8efdb846
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jul 24 10:01:04 2023 +0200

    camel-jms - Flaky test due to session gets closed which should be ignored.
---
 .../jms/JmsInOnlyDisableTimeToLiveTest.java        | 31 +++++++++++++++-------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyDisableTimeToLiveTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyDisableTimeToLiveTest.java
index 5fd0e8348d7..6dd5ad54586 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyDisableTimeToLiveTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyDisableTimeToLiveTest.java
@@ -27,9 +27,14 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jms.IllegalStateException;
 
 public class JmsInOnlyDisableTimeToLiveTest extends AbstractJMSTest {
 
+    private static final Logger LOG = LoggerFactory.getLogger(JmsInOnlyDisableTimeToLiveTest.class);
+
     @Order(2)
     @RegisterExtension
     public static CamelContextExtension camelContextExtension = new DefaultCamelContextExtension();
@@ -144,17 +149,25 @@ public class JmsInOnlyDisableTimeToLiveTest extends AbstractJMSTest {
             // loop to empty queue
             while (true) {
                 // receive the message from the queue, wait at most 2 sec
-                String msg = consumer.receiveBody("activemq:JmsInOnlyDisableTimeToLiveTest.in", 2000, String.class);
-                if (msg == null) {
-                    // no more messages in queue
-                    break;
+                try {
+                    String msg = consumer.receiveBody("activemq:JmsInOnlyDisableTimeToLiveTest.in", 2000, String.class);
+                    if (msg == null) {
+                        // no more messages in queue
+                        break;
+                    }
+                    // do something with body
+                    msg = "Hello " + msg;
+
+                    // send it to the next queue
+                    producer.sendBodyAndHeader("activemq:JmsInOnlyDisableTimeToLiveTest.out", msg, "number", count++);
+                } catch (IllegalStateException e) {
+                    if (e.getCause() instanceof jakarta.jms.IllegalStateException) {
+                        // session is closed
+                        LOG.warn("JMS Session is closed");
+                        break;
+                    }
                 }
 
-                // do something with body
-                msg = "Hello " + msg;
-
-                // send it to the next queue
-                producer.sendBodyAndHeader("activemq:JmsInOnlyDisableTimeToLiveTest.out", msg, "number", count++);
             }
         }
     }