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/10/10 10:28:09 UTC

[1/6] git commit: CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler

Updated Branches:
  refs/heads/camel-2.11.x 63c182b2e -> d1125a984
  refs/heads/camel-2.12.x 76cdbd87e -> 7f1400e82


CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler


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

Branch: refs/heads/camel-2.11.x
Commit: d1125a9841792f3d1f6c9b382329f0c8942332ae
Parents: 3c310aa
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 10 10:26:38 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 10 10:27:51 2013 +0200

----------------------------------------------------------------------
 .../RoutingSlipNoErrorHandlerTest.java          | 60 ++++++++++++++++++++
 .../processor/SendToNoErrorHandlerTest.java     | 60 ++++++++++++++++++++
 2 files changed, 120 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d1125a98/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
new file mode 100644
index 0000000..0bd644c
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RoutingSlipNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testRoutingSlipNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .routingSlip().constant("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d1125a98/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
new file mode 100644
index 0000000..aece2d4
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class SendToNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testSendToNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .to("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}


[2/6] git commit: CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler

Posted by da...@apache.org.
CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler


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

Branch: refs/heads/camel-2.11.x
Commit: 3c310aadd0a4619dac030960438d3bbfe66b84f0
Parents: 63c182b
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 10 08:04:37 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 10 10:27:51 2013 +0200

----------------------------------------------------------------------
 .../camel/builder/NoErrorHandlerBuilder.java    | 25 +++++++-
 .../camel/processor/MulticastProcessor.java     | 35 ++++++++----
 .../RecipientListNoErrorHandlerTest.java        | 60 ++++++++++++++++++++
 3 files changed, 108 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3c310aad/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
index d9e650a..1c3ad0e 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
@@ -16,7 +16,10 @@
  */
 package org.apache.camel.builder;
 
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.processor.DelegateAsyncProcessor;
 import org.apache.camel.spi.RouteContext;
 
 /**
@@ -31,7 +34,27 @@ import org.apache.camel.spi.RouteContext;
 public class NoErrorHandlerBuilder extends ErrorHandlerBuilderSupport {
 
     public Processor createErrorHandler(RouteContext routeContext, Processor processor) {
-        return processor;
+        return new DelegateAsyncProcessor(processor) {
+            @Override
+            public boolean process(final Exchange exchange, final AsyncCallback callback) {
+                return super.process(exchange, new AsyncCallback() {
+                    @Override
+                    public void done(boolean doneSync) {
+                        exchange.removeProperty(Exchange.REDELIVERY_EXHAUSTED);
+                        callback.done(doneSync);
+                    }
+                });
+            }
+
+            @Override
+            public String toString() {
+                if (processor == null) {
+                    // if no output then dont do any description
+                    return "";
+                }
+                return "NoErrorHandler[" + processor + "]";
+            }
+        };
     }
 
     public boolean supportTransacted() {

http://git-wip-us.apache.org/repos/asf/camel/blob/3c310aad/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index cdce14c..6c0aabe 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -733,15 +733,15 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
      * when using the asynchronous routing engine. And therefore we want the logic in one method instead
      * of being scattered.
      *
-     * @param original    the original exchange
-     * @param subExchange the current sub exchange, can be <tt>null</tt> for the synchronous part
-     * @param pairs       the pairs with the exchanges to process
-     * @param callback    the callback
-     * @param doneSync    the <tt>doneSync</tt> parameter to call on callback
-     * @param exhaust     whether or not error handling is exhausted
+     * @param original     the original exchange
+     * @param subExchange  the current sub exchange, can be <tt>null</tt> for the synchronous part
+     * @param pairs        the pairs with the exchanges to process
+     * @param callback     the callback
+     * @param doneSync     the <tt>doneSync</tt> parameter to call on callback
+     * @param forceExhaust whether or not error handling is exhausted
      */
     protected void doDone(Exchange original, Exchange subExchange, final Iterable<ProcessorExchangePair> pairs,
-                          AsyncCallback callback, boolean doneSync, boolean exhaust) {
+                          AsyncCallback callback, boolean doneSync, boolean forceExhaust) {
 
         // we are done so close the pairs iterator
         if (pairs != null && pairs instanceof Closeable) {
@@ -751,16 +751,18 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
         // cleanup any per exchange aggregation strategy
         removeAggregationStrategyFromExchange(original);
 
+        // we need to know if there was an exception, and if the stopOnException option was enabled
+        // also we would need to know if any error handler has attempted redelivery and exhausted
         boolean stoppedOnException = false;
+        boolean exception = false;
+        boolean exhaust = forceExhaust || subExchange != null && (subExchange.getException() != null || ExchangeHelper.isRedeliveryExhausted(subExchange));
         if (original.getException() != null || subExchange != null && subExchange.getException() != null) {
             // there was an exception and we stopped
             stoppedOnException = isStopOnException();
-            // multicast uses error handling on its output processors and they have tried to redeliver
-            // so we shall signal back to the other error handlers that we are exhausted and they should not
-            // also try to redeliver as we will then do that twice
-            original.setProperty(Exchange.REDELIVERY_EXHAUSTED, exhaust);
+            exception = true;
         }
 
+        // must copy results at this point
         if (subExchange != null) {
             if (stoppedOnException) {
                 // if we stopped due an exception then only propagte the exception
@@ -770,6 +772,17 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
                 ExchangeHelper.copyResults(original, subExchange);
             }
         }
+
+        // .. and then if there was an exception we need to configure the redelivery exhaust
+        // for example the noErrorHandler will not cause redelivery exhaust so if this error
+        // handled has been in use, then the exhaust would be false (if not forced)
+        if (exception) {
+            // multicast uses error handling on its output processors and they have tried to redeliver
+            // so we shall signal back to the other error handlers that we are exhausted and they should not
+            // also try to redeliver as we will then do that twice
+            original.setProperty(Exchange.REDELIVERY_EXHAUSTED, exhaust);
+        }
+
         callback.done(doneSync);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3c310aad/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java
new file mode 100644
index 0000000..f037e52
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RecipientListNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testRecipientListNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .recipientList().constant("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}


[3/6] git commit: Added unit test based on user forum issue

Posted by da...@apache.org.
Added unit test based on user forum issue


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

Branch: refs/heads/camel-2.12.x
Commit: ade5eb0a2919f52edf777aec89595c00a45b181a
Parents: 76cdbd8
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Oct 9 12:48:06 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 10 10:28:01 2013 +0200

----------------------------------------------------------------------
 ...yNullErrorHandlerUseOriginalMessageTest.java | 74 ++++++++++++++++++++
 1 file changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ade5eb0a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSetBodyNullErrorHandlerUseOriginalMessageTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSetBodyNullErrorHandlerUseOriginalMessageTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSetBodyNullErrorHandlerUseOriginalMessageTest.java
new file mode 100644
index 0000000..55a7536
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSetBodyNullErrorHandlerUseOriginalMessageTest.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+public class JmsSetBodyNullErrorHandlerUseOriginalMessageTest extends CamelTestSupport {
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createPersistentConnectionFactory();
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+        return camelContext;
+    }
+
+    @Test
+    public void testSetNull() throws Exception {
+        getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:bar").message(0).body().isNull();
+
+        template.sendBody("activemq:queue:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        String body = consumer.receiveBody("activemq:queue:dead", 5000, String.class);
+        assertEquals("Hello World", body);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("activemq:queue:dead").useOriginalMessage());
+
+                from("activemq:queue:foo")
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            // an end user may set the message body explicit to null
+                            exchange.getIn().setBody(null);
+                        }
+                    })
+                    .to("mock:bar")
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+}


[4/6] git commit: CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler

Posted by da...@apache.org.
CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler


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

Branch: refs/heads/camel-2.12.x
Commit: 7f9512faadaa9d9d218db14361d5fea77c1e0c4d
Parents: ade5eb0
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 10 08:04:37 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 10 10:28:01 2013 +0200

----------------------------------------------------------------------
 .../camel/builder/NoErrorHandlerBuilder.java    | 25 +++++++-
 .../camel/processor/MulticastProcessor.java     | 35 ++++++++----
 .../RecipientListNoErrorHandlerTest.java        | 60 ++++++++++++++++++++
 3 files changed, 108 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7f9512fa/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
index d9e650a..1c3ad0e 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
@@ -16,7 +16,10 @@
  */
 package org.apache.camel.builder;
 
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.processor.DelegateAsyncProcessor;
 import org.apache.camel.spi.RouteContext;
 
 /**
@@ -31,7 +34,27 @@ import org.apache.camel.spi.RouteContext;
 public class NoErrorHandlerBuilder extends ErrorHandlerBuilderSupport {
 
     public Processor createErrorHandler(RouteContext routeContext, Processor processor) {
-        return processor;
+        return new DelegateAsyncProcessor(processor) {
+            @Override
+            public boolean process(final Exchange exchange, final AsyncCallback callback) {
+                return super.process(exchange, new AsyncCallback() {
+                    @Override
+                    public void done(boolean doneSync) {
+                        exchange.removeProperty(Exchange.REDELIVERY_EXHAUSTED);
+                        callback.done(doneSync);
+                    }
+                });
+            }
+
+            @Override
+            public String toString() {
+                if (processor == null) {
+                    // if no output then dont do any description
+                    return "";
+                }
+                return "NoErrorHandler[" + processor + "]";
+            }
+        };
     }
 
     public boolean supportTransacted() {

http://git-wip-us.apache.org/repos/asf/camel/blob/7f9512fa/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index a3bca76..7584adf 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -733,15 +733,15 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
      * when using the asynchronous routing engine. And therefore we want the logic in one method instead
      * of being scattered.
      *
-     * @param original    the original exchange
-     * @param subExchange the current sub exchange, can be <tt>null</tt> for the synchronous part
-     * @param pairs       the pairs with the exchanges to process
-     * @param callback    the callback
-     * @param doneSync    the <tt>doneSync</tt> parameter to call on callback
-     * @param exhaust     whether or not error handling is exhausted
+     * @param original     the original exchange
+     * @param subExchange  the current sub exchange, can be <tt>null</tt> for the synchronous part
+     * @param pairs        the pairs with the exchanges to process
+     * @param callback     the callback
+     * @param doneSync     the <tt>doneSync</tt> parameter to call on callback
+     * @param forceExhaust whether or not error handling is exhausted
      */
     protected void doDone(Exchange original, Exchange subExchange, final Iterable<ProcessorExchangePair> pairs,
-                          AsyncCallback callback, boolean doneSync, boolean exhaust) {
+                          AsyncCallback callback, boolean doneSync, boolean forceExhaust) {
 
         // we are done so close the pairs iterator
         if (pairs != null && pairs instanceof Closeable) {
@@ -751,16 +751,18 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
         // cleanup any per exchange aggregation strategy
         removeAggregationStrategyFromExchange(original);
 
+        // we need to know if there was an exception, and if the stopOnException option was enabled
+        // also we would need to know if any error handler has attempted redelivery and exhausted
         boolean stoppedOnException = false;
+        boolean exception = false;
+        boolean exhaust = forceExhaust || subExchange != null && (subExchange.getException() != null || ExchangeHelper.isRedeliveryExhausted(subExchange));
         if (original.getException() != null || subExchange != null && subExchange.getException() != null) {
             // there was an exception and we stopped
             stoppedOnException = isStopOnException();
-            // multicast uses error handling on its output processors and they have tried to redeliver
-            // so we shall signal back to the other error handlers that we are exhausted and they should not
-            // also try to redeliver as we will then do that twice
-            original.setProperty(Exchange.REDELIVERY_EXHAUSTED, exhaust);
+            exception = true;
         }
 
+        // must copy results at this point
         if (subExchange != null) {
             if (stoppedOnException) {
                 // if we stopped due an exception then only propagte the exception
@@ -770,6 +772,17 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
                 ExchangeHelper.copyResults(original, subExchange);
             }
         }
+
+        // .. and then if there was an exception we need to configure the redelivery exhaust
+        // for example the noErrorHandler will not cause redelivery exhaust so if this error
+        // handled has been in use, then the exhaust would be false (if not forced)
+        if (exception) {
+            // multicast uses error handling on its output processors and they have tried to redeliver
+            // so we shall signal back to the other error handlers that we are exhausted and they should not
+            // also try to redeliver as we will then do that twice
+            original.setProperty(Exchange.REDELIVERY_EXHAUSTED, exhaust);
+        }
+
         callback.done(doneSync);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7f9512fa/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java
new file mode 100644
index 0000000..f037e52
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RecipientListNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testRecipientListNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .recipientList().constant("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}


[5/6] git commit: Revert back arquillian version due cid-itest fails due API breakings.

Posted by da...@apache.org.
Revert back arquillian version due cid-itest fails due API breakings.


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

Branch: refs/heads/camel-2.12.x
Commit: 20f753b55bbbb6685e0a0abaf8473a278aedba10
Parents: 7f9512f
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 10 09:23:51 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 10 10:28:02 2013 +0200

----------------------------------------------------------------------
 parent/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/20f753b5/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 110c4b7..c4fecc4 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -49,7 +49,7 @@
     <aries-blueprint-proxy-version>1.0.0</aries-blueprint-proxy-version>
     <aries-blueprint-proxy-impl-version>1.0.1</aries-blueprint-proxy-impl-version>
     <aries-util-version>1.1.0</aries-util-version>
-    <arquillian-junit-container-version>1.0.4.Final</arquillian-junit-container-version>
+    <arquillian-junit-container-version>1.0.0.CR7</arquillian-junit-container-version>
     <arquillian-weld-ee-embedded-version>1.0.0.CR3</arquillian-weld-ee-embedded-version>
     <asm-bundle-version>3.3_2</asm-bundle-version>
     <asm-version>3.1</asm-version>


[6/6] git commit: CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler

Posted by da...@apache.org.
CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler


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

Branch: refs/heads/camel-2.12.x
Commit: 7f1400e82d2ceb87fc122f4d9bb17204b97a5ade
Parents: 20f753b
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 10 10:26:38 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 10 10:28:02 2013 +0200

----------------------------------------------------------------------
 .../RoutingSlipNoErrorHandlerTest.java          | 60 ++++++++++++++++++++
 .../processor/SendToNoErrorHandlerTest.java     | 60 ++++++++++++++++++++
 2 files changed, 120 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7f1400e8/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
new file mode 100644
index 0000000..0bd644c
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RoutingSlipNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testRoutingSlipNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .routingSlip().constant("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7f1400e8/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
new file mode 100644
index 0000000..aece2d4
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class SendToNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testSendToNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .to("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}