camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r727409 - in /activemq/camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/java/org/apache/camel/processor/aggregate/ camel-core/src/test/java/org/apache/camel/processor/
Date Wed, 17 Dec 2008 15:07:57 GMT
Author: ningjiang
Date: Wed Dec 17 07:07:56 2008
New Revision: 727409

URL: http://svn.apache.org/viewvc?rev=727409&view=rev
Log:
Merged revisions 727377 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r727377 | ningjiang | 2008-12-17 21:31:26 +0800 (Wed, 17 Dec 2008) | 1 line
  
  CAMEL-159 added testcase for propagating exception in Splitter
........

Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/aggregate/UseLatestAggregationStrategy.java
    activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 17 07:07:56 2008
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,726640-726645,726932,727113,727375
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,726640-726645,726932,727113,727375,727377

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

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java?rev=727409&r1=727408&r2=727409&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
(original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
Wed Dec 17 07:07:56 2008
@@ -186,8 +186,11 @@
                 Processor producer = pair.getProcessor();
                 Exchange subExchange = pair.getExchange();
                 updateNewExchange(subExchange, i, pairs);
-
-                producer.process(subExchange);
+                try {
+                    producer.process(subExchange);
+                } catch (Exception exception) {
+                    subExchange.setException(exception);
+                }
                 doAggregate(result, subExchange);
                 i++;
             }

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/aggregate/UseLatestAggregationStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/aggregate/UseLatestAggregationStrategy.java?rev=727409&r1=727408&r2=727409&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/aggregate/UseLatestAggregationStrategy.java
(original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/aggregate/UseLatestAggregationStrategy.java
Wed Dec 17 07:07:56 2008
@@ -28,6 +28,13 @@
 public class UseLatestAggregationStrategy implements AggregationStrategy {
 
     public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+        newExchange.setException(checkException(oldExchange, newExchange));
         return newExchange;
     }
+    
+    protected Throwable checkException(Exchange oldExchange, Exchange newExchange) {
+        return newExchange.getException() != null
+                ? newExchange.getException()
+                : oldExchange.getException();
+    }
 }

Modified: activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java?rev=727409&r1=727408&r2=727409&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
(original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
Wed Dec 17 07:07:56 2008
@@ -20,6 +20,7 @@
 import java.util.Set;
 import java.util.TreeSet;
 
+import org.apache.camel.CamelException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -179,14 +180,50 @@
         }
 
     }
+    
+    public void testSplitterWithException() throws Exception {
+        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
+        resultEndpoint.expectedMessageCount(4);
+        resultEndpoint.expectedHeaderReceived("foo", "bar");
+        
+        MockEndpoint failedEndpoint = getMockEndpoint("mock:failed");
+        failedEndpoint.expectedMessageCount(1);
+        failedEndpoint.expectedHeaderReceived("foo", "bar");
+        
+        Exchange result = template.send("direct:exception", new Processor() {
+            public void process(Exchange exchange) {
+                Message in = exchange.getIn();
+                in.setBody("James,Guillaume,Hiram,Rob,Exception");
+                in.setHeader("foo", "bar");
+            }
+        });
+        
+        assertTrue("The result exchange should have a camel exception", result.getException()
instanceof CamelException);
+
+        assertMockEndpointsSatisfied();
+    }
 
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
+                errorHandler(deadLetterChannel("mock:failed").maximumRedeliveries(0));
                 from("direct:seqential").splitter(body().tokenize(","), new UseLatestAggregationStrategy()).to("mock:result");
                 from("direct:parallel").splitter(body().tokenize(","), new MyAggregationStrategy(),
true).to("mock:result");
                 from("direct:streaming").splitter(body().tokenize(",")).streaming().to("mock:result");
                 from("direct:parallel-streaming").splitter(body().tokenize(","), new MyAggregationStrategy(),
true).streaming().to("mock:result");
+                from("direct:exception")
+                    .splitter(body().tokenize(","))
+                    .aggregationStrategy(new MyAggregationStrategy())
+                    .parallelProcessing(true).streaming()
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            String string = exchange.getIn().getBody(String.class);
+                            if ("Exception".equals(string)) {
+                                throw new CamelException("Just want to throw exception here");
+                            }
+                        
+                        }                    
+                    }).to("mock:result");
             }
         };
     }



Mime
View raw message