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 2020/08/04 19:33:28 UTC

[camel] branch camel-3.4.x updated: CAMEL-15350: camel-sjms - batch consumer fix recover issue when any kind of exception is thrown. Thanks to Brad Harvey for the patch.

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

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


The following commit(s) were added to refs/heads/camel-3.4.x by this push:
     new 604f496  CAMEL-15350: camel-sjms - batch consumer fix recover issue when any kind of exception is thrown. Thanks to Brad Harvey for the patch.
604f496 is described below

commit 604f496ae272f825222a01924260a0057e4df4d5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Aug 4 21:32:18 2020 +0200

    CAMEL-15350: camel-sjms - batch consumer fix recover issue when any kind of exception is thrown. Thanks to Brad Harvey for the patch.
---
 .../org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java
index 0d94deb..6452fc6 100644
--- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java
+++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java
@@ -315,8 +315,9 @@ public class SjmsBatchConsumer extends DefaultConsumer {
                 // only want to try AGAIN if the keepAlive is set.
                 do {
                     // a batch corresponds to a single session that will be committed or rolled back by a background thread
-                    final Session session = connection.createSession(TRANSACTED, Session.CLIENT_ACKNOWLEDGE);
+                    Session session = null;
                     try {
+                        session = connection.createSession(TRANSACTED, Session.CLIENT_ACKNOWLEDGE);
                         // only batch consumption from queues is supported - it makes no sense to transactionally consume
                         // from a topic as you don't car about message loss, users can just use a regular aggregator instead
                         Queue queue = session.createQueue(destinationName);
@@ -345,7 +346,7 @@ public class SjmsBatchConsumer extends DefaultConsumer {
             } catch (Throwable ex) {
                 // from consumeBatchesOnLoop
                 // catch anything besides the IllegalStateException and exit the application
-                getExceptionHandler().handleException("Exception caught consuming from " + destinationName, ex);
+                getExceptionHandler().handleException("Exiting consumption loop due to exception caught consuming from " + destinationName, ex);
             } finally {
                 // indicate that we have shut down
                 CountDownLatch consumersShutdownLatch = consumersShutdownLatchRef.get();
@@ -367,7 +368,9 @@ public class SjmsBatchConsumer extends DefaultConsumer {
 
         private void closeJmsSession(Session session) {
             try {
-                session.close();
+                if (session != null) {
+                    session.close();
+                }
             } catch (JMSException ex2) {
                 // only include stacktrace in debug logging
                 if (LOG.isDebugEnabled()) {