Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x fadf8d472 -> cd7e6fc3c
  refs/heads/camel-2.16.x 0360a235b -> 88dd249fe


CAMEL-9567: camel-sjms - the consumer should stop in suspend so graceful 
shutdown can stop the consumer take in new jms messages, while the inflight is 
being processed. This is already fixed from Camel 2.17 onwards. So this only 
needs to go on 2.16.x and 2.15.x branches.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/88dd249f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/88dd249f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/88dd249f

Branch: refs/heads/camel-2.16.x
Commit: 88dd249fe0aae965d7c9736e0911082f62efed16
Parents: 0360a23
Author: Claus Ibsen <davscl...@apache.org>
Authored: Mon Feb 8 18:47:42 2016 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Feb 8 18:47:42 2016 +0100

----------------------------------------------------------------------
 .../camel/component/sjms/SjmsConsumer.java      | 36 ++++++++++++++++----
 1 file changed, 29 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/88dd249f/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsConsumer.java
 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsConsumer.java
index 162e252..0b9c25e 100644
--- 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsConsumer.java
+++ 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsConsumer.java
@@ -103,9 +103,7 @@ public class SjmsConsumer extends DefaultConsumer {
         return (SjmsEndpoint) super.getEndpoint();
     }
 
-    @Override
-    protected void doStart() throws Exception {
-        super.doStart();
+    protected void startListener() throws Exception {
         this.executor = 
getEndpoint().getCamelContext().getExecutorServiceManager().newDefaultThreadPool(this,
 "SjmsConsumer");
         if (consumers == null) {
             consumers = new GenericObjectPool<MessageConsumerResources>(new 
MessageConsumerResourcesFactory());
@@ -139,9 +137,7 @@ public class SjmsConsumer extends DefaultConsumer {
         }
     }
 
-    @Override
-    protected void doStop() throws Exception {
-        super.doStop();
+    protected void stopListener() throws Exception {
         if (asyncStart != null && !asyncStart.isDone()) {
             asyncStart.cancel(true);
         }
@@ -170,9 +166,36 @@ public class SjmsConsumer extends DefaultConsumer {
         }
         if (this.executor != null) {
             
getEndpoint().getCamelContext().getExecutorServiceManager().shutdownGraceful(this.executor);
+            this.executor = null;
         }
     }
 
+    @Override
+    protected void doStart() throws Exception {
+        startListener();
+        super.doStart();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        stopListener();
+        super.doStop();
+    }
+
+    @Override
+    protected void doResume() throws Exception {
+        // do the same logic as start
+        startListener();
+        super.doResume();
+    }
+
+    @Override
+    protected void doSuspend() throws Exception {
+        // do the same logic as stop
+        stopListener();
+        super.doSuspend();
+    }
+
     /**
      * Creates a {@link MessageConsumerResources} with a dedicated
      * {@link Session} required for transacted and InOut consumers.
@@ -197,7 +220,6 @@ public class SjmsConsumer extends DefaultConsumer {
         return answer;
     }
 
-
     /**
      * Helper factory method used to create a MessageListener based on the MEP
      *

Reply via email to