This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 3567090 CAMEL-15350: camel-sjms - batch consumer fix recover issue when any kind of exception is thrown. Thanks to Brad Harvey for the patch. 3567090 is described below commit 3567090026790621a0848a87818172a050a94689 Author: Claus Ibsen <claus.ib...@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()) {