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 2013/08/26 20:02:20 UTC

[2/2] git commit: CAMEL-5376: mail consumer commit/rollback logc do not allow handover to ensure running on same thread as polling to use the same mail session.

CAMEL-5376: mail consumer commit/rollback logc do not allow handover to ensure running on same thread as polling to use the same mail session.


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

Branch: refs/heads/camel-2.11.x
Commit: f0fbe072300a291913b6c14fbc60a8ae75275810
Parents: 7f149a5
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Aug 26 20:01:38 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Aug 26 20:02:02 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/mail/MailConsumer.java     | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f0fbe072/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
index f26cf82..829b57f 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
@@ -32,6 +32,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.ScheduledBatchPollingConsumer;
 import org.apache.camel.spi.Synchronization;
+import org.apache.camel.support.SynchronizationAdapter;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
@@ -180,7 +181,7 @@ public class MailConsumer extends ScheduledBatchPollingConsumer {
             final Message mail = exchange.getIn(MailMessage.class).getOriginalMessage();
 
             // add on completion to handle after work when the exchange is done
-            exchange.addOnCompletion(new Synchronization() {
+            exchange.addOnCompletion(new SynchronizationAdapter() {
                 public void onComplete(Exchange exchange) {
                     processCommit(mail, exchange);
                 }
@@ -190,6 +191,13 @@ public class MailConsumer extends ScheduledBatchPollingConsumer {
                 }
 
                 @Override
+                public boolean allowHandover() {
+                    // do not allow handover as the commit/rollback logic needs to be executed
+                    // on the same session that polled the messages
+                    return false;
+                }
+
+                @Override
                 public String toString() {
                     return "MailConsumerOnCompletion";
                 }