camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1438017 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/resources/org/apache/camel/spring/processor/
Date Thu, 24 Jan 2013 14:32:33 GMT
Author: ningjiang
Date: Thu Jan 24 14:32:32 2013
New Revision: 1438017

URL: http://svn.apache.org/viewvc?rev=1438017&view=rev
Log:
CAMEL-6005 fixed the issue of using shareUnitOfWork within multicast

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastSubUnitOfWorkTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMulticastSubUnitOfWorkTest.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java?rev=1438017&r1=1438016&r2=1438017&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
Thu Jan 24 14:32:32 2013
@@ -877,9 +877,12 @@ public class MulticastProcessor extends 
             } catch (Exception e) {
                 throw ObjectHelper.wrapRuntimeCamelException(e);
             }
-
-            // add to cache
-            errorHandlers.putIfAbsent(key, answer);
+            // here we don't cache the ChildUnitOfWorkProcessor
+            // As the UnitOfWorkProcess will be delegate to the Parent
+            if (!(answer instanceof ChildUnitOfWorkProcessor)) {
+                // add to cache
+                errorHandlers.putIfAbsent(key, answer);
+            }
         } else {
             // and wrap in unit of work processor so the copy exchange also can run under
UoW
             answer = createUnitOfWorkProcessor(routeContext, processor, exchange);

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastSubUnitOfWorkTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastSubUnitOfWorkTest.java?rev=1438017&r1=1438016&r2=1438017&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastSubUnitOfWorkTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastSubUnitOfWorkTest.java
Thu Jan 24 14:32:32 2013
@@ -58,6 +58,14 @@ public class MulticastSubUnitOfWorkTest 
 
         assertEquals(4, counter); // 1 first + 3 redeliveries
     }
+    
+    public void testMulticastException() throws Exception {
+        getMockEndpoint("mock:dead").expectedBodiesReceived("Hello", "Hi", "Bye");
+        template.sendBody("direct:e", "Hello");
+        template.sendBody("direct:e", "Hi");
+        template.sendBody("direct:e", "Bye");
+        assertMockEndpointsSatisfied();
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -82,6 +90,12 @@ public class MulticastSubUnitOfWorkTest 
                 from("direct:b")
                     .process(new MyProcessor())
                     .to("mock:b");
+                
+                from("direct:e")
+                    .multicast().shareUnitOfWork()
+                        .throwException(new IllegalArgumentException("exception1"))
+                        .throwException(new IllegalArgumentException("exception2"))
+                    .end();
             }
         };
     }

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMulticastSubUnitOfWorkTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMulticastSubUnitOfWorkTest.xml?rev=1438017&r1=1438016&r2=1438017&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMulticastSubUnitOfWorkTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMulticastSubUnitOfWorkTest.xml
Thu Jan 24 14:32:32 2013
@@ -24,6 +24,7 @@
 
   <bean id="myPreProcessor" class="org.apache.camel.processor.MulticastSubUnitOfWorkTest$MyPreProcessor"/>
   <bean id="myProcessor" class="org.apache.camel.processor.MulticastSubUnitOfWorkTest$MyProcessor"/>
+  <bean name="anException" class="java.lang.IllegalArgumentException"/>
 
   <!-- START SNIPPET: e1 -->
   <camelContext errorHandlerRef="dlc" xmlns="http://camel.apache.org/schema/spring">
@@ -57,6 +58,14 @@
       <process ref="myProcessor"/>
       <to uri="mock:b"/>
     </route>
+    
+    <route>
+      <from uri="direct:e"/>
+      <multicast shareUnitOfWork="true">
+        <throwException ref="anException"/>
+        <throwException ref="anException"/>
+      </multicast>
+    </route>
 
   </camelContext>
   <!-- END SNIPPET: e1 -->



Mime
View raw message