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 2012/02/23 10:37:47 UTC

svn commit: r1292726 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/component/seda/ camel-core/src/test/java/org/apache/camel/component/seda/

Author: davsclaus
Date: Thu Feb 23 09:37:47 2012
New Revision: 1292726

URL: http://svn.apache.org/viewvc?rev=1292726&view=rev
Log:
CAMEL-5033: Seda producer in synced mode should not handover on completion tasks.

Added:
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteOnCompletionTest.java
      - copied unchanged from r1292725, camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteOnCompletionTest.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskNewerOnCompletionTest.java
      - copied unchanged from r1292725, camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskNewerOnCompletionTest.java
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 23 09:37:47 2012
@@ -1 +1 @@
-/camel/trunk:1243046,1243057,1243234,1244518,1244644,1244859,1244861,1244864,1244870,1244872,1245021,1291555,1291727,1291848,1291864,1292114,1292384
+/camel/trunk:1243046,1243057,1243234,1244518,1244644,1244859,1244861,1244864,1244870,1244872,1245021,1291555,1291727,1291848,1291864,1292114,1292384,1292725

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java?rev=1292726&r1=1292725&r2=1292726&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java Thu Feb 23 09:37:47 2012
@@ -58,12 +58,6 @@ public class SedaProducer extends Defaul
 
     @Override
     public boolean process(final Exchange exchange, final AsyncCallback callback) {
-        // use a new copy of the exchange to route async and handover the on completion to the new copy
-        // so its the new copy that performs the on completion callback when its done
-        Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, true);
-        // set a new from endpoint to be the seda queue
-        copy.setFromEndpoint(endpoint);
-
         WaitForTaskToComplete wait = waitForTaskToComplete;
         if (exchange.getProperty(Exchange.ASYNC_WAIT) != null) {
             wait = exchange.getProperty(Exchange.ASYNC_WAIT, WaitForTaskToComplete.class);
@@ -72,6 +66,9 @@ public class SedaProducer extends Defaul
         if (wait == WaitForTaskToComplete.Always
             || (wait == WaitForTaskToComplete.IfReplyExpected && ExchangeHelper.isOutCapable(exchange))) {
 
+            // do not handover the completion as we wait for the copy to complete, and copy its result back when it done
+            Exchange copy = prepareCopy(exchange, false);
+
             // latch that waits until we are complete
             final CountDownLatch latch = new CountDownLatch(1);
 
@@ -145,6 +142,8 @@ public class SedaProducer extends Defaul
             }
         } else {
             // no wait, eg its a InOnly then just add to queue and return
+            // handover the completion so its the copy which performs that, as we do not wait
+            Exchange copy = prepareCopy(exchange, true);
             log.trace("Adding Exchange to queue: {}", copy);
             addToQueue(copy);
         }
@@ -155,6 +154,14 @@ public class SedaProducer extends Defaul
         return true;
     }
 
+    protected Exchange prepareCopy(Exchange exchange, boolean handover) {
+        // use a new copy of the exchange to route async
+        Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, handover);
+        // set a new from endpoint to be the seda queue
+        copy.setFromEndpoint(endpoint);
+        return copy;
+    }
+
     @Override
     protected void doStart() throws Exception {
         super.doStart();