camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r773801 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/s...
Date Tue, 12 May 2009 06:45:02 GMT
Author: davsclaus
Date: Tue May 12 06:45:01 2009
New Revision: 773801

URL: http://svn.apache.org/viewvc?rev=773801&view=rev
Log:
CAMEL-1600: Added useOriginalExchange as option to DLC and onException, allowing you to use the original bodies to be moved into the dead letter queuer. So you can easier manually retry based on the original input, and not the modified current exchange that failed with an exception.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeWithFileTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceUseOriginalExchangeTest.java
      - copied, changed from r773474, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionUseOriginalExchangeTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.xml
      - copied, changed from r773783, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.xml
      - copied, changed from r773783, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml   (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Synchronization.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java?rev=773801&r1=773800&r2=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java Tue May 12 06:45:01 2009
@@ -50,6 +50,7 @@
     private Endpoint deadLetter;
     private String deadLetterUri;
     private Predicate handledPolicy;
+    private boolean useOriginalExchange;
 
     /**
      * Creates a default DeadLetterChannel with a default endpoint
@@ -78,7 +79,7 @@
 
     public Processor createErrorHandler(RouteContext routeContext, Processor processor) throws Exception {
         DeadLetterChannel answer = new DeadLetterChannel(processor, getFailureProcessor(), deadLetterUri, onRedelivery,
-                getRedeliveryPolicy(), getLogger(), getExceptionPolicyStrategy(), getHandledPolicy());
+                getRedeliveryPolicy(), getLogger(), getExceptionPolicyStrategy(), getHandledPolicy(), isUseOriginalExchange());
         // must enable stream cache as DeadLetterChannel can do redeliveries and
         // thus it needs to be able to read the stream again
         configure(answer);
@@ -186,6 +187,9 @@
 
     /**
      * Sets the logger used for caught exceptions
+     *
+     * @param logger the logger
+     * @return the builder
      */
     public DeadLetterChannelBuilder logger(Logger logger) {
         setLogger(logger);
@@ -194,6 +198,9 @@
 
     /**
      * Sets the logging level of exceptions caught
+     *
+     * @param level the logging level
+     * @return the builder
      */
     public DeadLetterChannelBuilder loggingLevel(LoggingLevel level) {
         getLogger().setLevel(level);
@@ -202,6 +209,9 @@
 
     /**
      * Sets the log used for caught exceptions
+     *
+     * @param log the logger
+     * @return the builder
      */
     public DeadLetterChannelBuilder log(Log log) {
         getLogger().setLog(log);
@@ -210,6 +220,9 @@
 
     /**
      * Sets the log used for caught exceptions
+     *
+     * @param log the log name
+     * @return the builder
      */
     public DeadLetterChannelBuilder log(String log) {
         return log(LogFactory.getLog(log));
@@ -217,6 +230,9 @@
 
     /**
      * Sets the log used for caught exceptions
+     *
+     * @param log the log class
+     * @return the builder
      */
     public DeadLetterChannelBuilder log(Class log) {
         return log(LogFactory.getLog(log));
@@ -224,6 +240,8 @@
 
     /**
      * Sets the exception policy to use
+     *
+     * @return the builder
      */
     public DeadLetterChannelBuilder exceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy) {
         setExceptionPolicyStrategy(exceptionPolicyStrategy);
@@ -234,12 +252,34 @@
      * Sets a processor that should be processed <b>before</b> a redelivey attempt.
      * <p/>
      * Can be used to change the {@link org.apache.camel.Exchange} <b>before</b> its being redelivered.
+     *
+     * @return the builder
      */
     public DeadLetterChannelBuilder onRedelivery(Processor processor) {
         setOnRedelivery(processor);
         return this;
     }
 
+    /**
+     * Will use the original input {@link Exchange} when an {@link Exchange} is moved to the dead letter queue.
+     * <p/>
+     * <b>Notice:</b> this only applies when all redeliveries attempt have failed and the {@link Exchange} is doomed for failure.
+     * <br/>
+     * Instead of using the current inprogress {@link Exchange} IN body we use the original IN body instead. This allows
+     * you to store the original input in the dead letter queue instead of the inprogress snapshot of the IN body.
+     * For instance if you route transform the IN body during routing and then failed. With the original exchange
+     * store in the dead letter queue it might be easier to manually re submit the {@link Exchange} again as the IN body
+     * is the same as when Camel received it. So you should be able to send the {@link Exchange} to the same input.
+     * <p/>
+     * By default this feature is off.
+     *
+     * @return the builder
+     */
+    public DeadLetterChannelBuilder useOriginalExchange() {
+        setUseOriginalExchange(true);
+        return this;
+    }
+
     // Properties
     // -------------------------------------------------------------------------
 
@@ -339,6 +379,14 @@
         handled(handled);
     }
 
+    public boolean isUseOriginalExchange() {
+        return useOriginalExchange;
+    }
+
+    public void setUseOriginalExchange(boolean useOriginalExchange) {
+        this.useOriginalExchange = useOriginalExchange;
+    }
+
     @Override
     public String toString() {
         return "DeadLetterChannelBuilder(" + deadLetterUri + ")";

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java?rev=773801&r1=773800&r2=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java Tue May 12 06:45:01 2009
@@ -38,8 +38,10 @@
     private String id;
     private List<Synchronization> synchronizations;
     private List<ProcessorDefinition> routeList;
+    private Exchange originalExchange;
 
-    public DefaultUnitOfWork() {
+    public DefaultUnitOfWork(Exchange exchange) {
+        this.originalExchange = exchange.copy();
     }
 
     public void start() throws Exception {
@@ -54,6 +56,8 @@
         if (routeList != null) {
             routeList.clear();
         }
+
+        originalExchange = null;
     }
 
     public synchronized void addSynchronization(Synchronization synchronization) {
@@ -107,4 +111,7 @@
         return Collections.unmodifiableList(routeList);
     }
 
+    public Exchange getOriginalExchange() {
+        return originalExchange;
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java?rev=773801&r1=773800&r2=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java Tue May 12 06:45:01 2009
@@ -65,6 +65,8 @@
     private ExpressionSubElementDefinition handled;
     @XmlAttribute(name = "onRedeliveryRef", required = false)
     private String onRedeliveryRef;
+    @XmlAttribute(name = "useOriginalExchange", required = false)
+    private Boolean useOriginalExchangePolicy = Boolean.FALSE;
     @XmlElementRef
     private List<ProcessorDefinition> outputs = new ArrayList<ProcessorDefinition>();
     @XmlTransient
@@ -359,6 +361,26 @@
     }
 
     /**
+     * Will use the original input {@link org.apache.camel.Exchange} when an {@link org.apache.camel.Exchange} is moved to the dead letter queue.
+     * <p/>
+     * <b>Notice:</b> this only applies when all redeliveries attempt have failed and the {@link org.apache.camel.Exchange} is doomed for failure.
+     * <br/>
+     * Instead of using the current inprogress {@link org.apache.camel.Exchange} IN body we use the original IN body instead. This allows
+     * you to store the original input in the dead letter queue instead of the inprogress snapshot of the IN body.
+     * For instance if you route transform the IN body during routing and then failed. With the original exchange
+     * store in the dead letter queue it might be easier to manually re submit the {@link org.apache.camel.Exchange} again as the IN body
+     * is the same as when Camel received it. So you should be able to send the {@link org.apache.camel.Exchange} to the same input.
+     * <p/>
+     * By default this feature is off.
+     *
+     * @return the builder
+     */
+    public OnExceptionDefinition useOriginalExchange() {
+        setUseOriginalExchangePolicy(Boolean.TRUE);
+        return this;
+    }
+
+    /**
      * Sets a processor that should be processed <b>before</b> a redelivey attempt.
      * <p/>
      * Can be used to change the {@link org.apache.camel.Exchange} <b>before</b> its being redelivered.
@@ -465,6 +487,13 @@
         this.onRedeliveryRef = onRedeliveryRef;
     }
 
+    public Boolean getUseOriginalExchangePolicy() {
+        return useOriginalExchangePolicy;
+    }
+
+    public void setUseOriginalExchangePolicy(Boolean useOriginalExchangePolicy) {
+        this.useOriginalExchangePolicy = useOriginalExchangePolicy;
+    }
 
     // Implementation methods
     //-------------------------------------------------------------------------

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?rev=773801&r1=773800&r2=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java Tue May 12 06:45:01 2009
@@ -54,12 +54,12 @@
     private final Processor redeliveryProcessor;
     private final RedeliveryPolicy redeliveryPolicy;
     private final Predicate handledPolicy;
-    private Logger logger;
+    private final Logger logger;
+    private final boolean useOriginalExchangePolicy;
 
     private class RedeliveryData {
         int redeliveryCounter;
         long redeliveryDelay;
-        boolean sync = true;
         Predicate retryUntilPredicate;
 
         // default behavior which can be overloaded on a per exception basis
@@ -67,6 +67,7 @@
         Processor deadLetterQueue = deadLetter;
         Processor onRedeliveryProcessor = redeliveryProcessor;
         Predicate handledPredicate = handledPolicy;
+        boolean useOriginalExchange = useOriginalExchangePolicy;
     }
     
     /**
@@ -80,10 +81,11 @@
      * @param logger                    logger to use for logging failures and redelivery attempts
      * @param exceptionPolicyStrategy   strategy for onException handling
      * @param handledPolicy             policy for handling failed exception that are moved to the dead letter queue
+     * @param useOriginalExchangePolicy should the original exchange be moved to the dead letter queue or the most recent exchange?
      */
     public DeadLetterChannel(Processor output, Processor deadLetter, String deadLetterUri, Processor redeliveryProcessor,
                              RedeliveryPolicy redeliveryPolicy, Logger logger, ExceptionPolicyStrategy exceptionPolicyStrategy,
-                             Predicate handledPolicy) {
+                             Predicate handledPolicy, boolean useOriginalExchangePolicy) {
         this.output = output;
         this.deadLetter = deadLetter;
         this.deadLetterUri = deadLetterUri;
@@ -91,6 +93,7 @@
         this.redeliveryPolicy = redeliveryPolicy;
         this.logger = logger;
         this.handledPolicy = handledPolicy;
+        this.useOriginalExchangePolicy = useOriginalExchangePolicy;
         setExceptionPolicy(exceptionPolicyStrategy);
     }
 
@@ -208,14 +211,6 @@
         return logger;
     }
 
-    /**
-     * Sets the logger strategy; which {@link com.sun.tools.javac.util.Log} to use and which
-     * {@link LoggingLevel} to use
-     */
-    public void setLogger(Logger logger) {
-        this.logger = logger;
-    }
-
     // Implementation methods
     // -------------------------------------------------------------------------
 
@@ -244,6 +239,7 @@
             data.currentRedeliveryPolicy = exceptionPolicy.createRedeliveryPolicy(exchange.getContext(), data.currentRedeliveryPolicy);
             data.handledPredicate = exceptionPolicy.getHandledPolicy();
             data.retryUntilPredicate = exceptionPolicy.getRetryUntilPolicy();
+            data.useOriginalExchange = exceptionPolicy.getUseOriginalExchangePolicy();
 
             // route specific failure handler?
             Processor processor = exceptionPolicy.getErrorHandler();
@@ -301,6 +297,25 @@
         // reset cached streams so they can be read again
         MessageHelper.resetStreamCache(exchange.getIn());
 
+        // prepare original exchange if it should be moved instead of most recent
+        if (data.useOriginalExchange) {
+            if (log.isTraceEnabled()) {
+                log.trace("Using the original exchange bodies in the DedLetterQueue instead of the current exchange bodies");
+            }
+
+            Exchange original = exchange.getUnitOfWork().getOriginalExchange();
+            // replace exchange IN/OUT with from original
+            exchange.setIn(original.getIn());
+            if (original.hasOut()) {
+                exchange.setOut(original.getOut());
+            } else {
+                exchange.setOut(null);
+            }
+        }
+
+        if (log.isTraceEnabled()) {
+            log.trace("DeadLetterQueue " + data.deadLetterQueue + " is processing Exchange: " + exchange);
+        }
         try {
             data.deadLetterQueue.process(exchange);
         } catch (Exception e) {
@@ -339,12 +354,17 @@
             newLogLevel = data.currentRedeliveryPolicy.getRetriesExhaustedLogLevel();
         }
         if (exchange.isRollbackOnly()) {
-            // log intented rollback on WARN level
             String msg = "Rollback exchange";
             if (exchange.getException() != null) {
                 msg = msg + " due: " + exchange.getException().getMessage();
             }
-            logger.log(msg, LoggingLevel.WARN);
+            if (newLogLevel == LoggingLevel.ERROR || newLogLevel == LoggingLevel.FATAL) {
+                // log intented rollback on maximum WARN level (no ERROR or FATAL)
+                logger.log(msg, LoggingLevel.WARN);
+            } else {
+                // otherwise use the desired logging level
+                logger.log(msg, newLogLevel);
+            }
         } else if (data.currentRedeliveryPolicy.isLogStackTrace() && e != null) {
             logger.log(message, e, newLogLevel);
         } else {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java?rev=773801&r1=773800&r2=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java Tue May 12 06:45:01 2009
@@ -41,7 +41,7 @@
         if (exchange.getUnitOfWork() == null) {
             // If there is no existing UoW, then we should start one and
             // terminate it once processing is completed for the exchange.
-            final DefaultUnitOfWork uow = new DefaultUnitOfWork();
+            final DefaultUnitOfWork uow = new DefaultUnitOfWork(exchange);
             exchange.setUnitOfWork(uow);
             try {
                 uow.start();

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Synchronization.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Synchronization.java?rev=773801&r1=773800&r2=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Synchronization.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Synchronization.java Tue May 12 06:45:01 2009
@@ -24,6 +24,7 @@
  * <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/transaction/
  * support/TransactionSynchronization.html">TransactionSynchronization</a>
  *
+ * @deprecated a new synchronization API is planned for Camel 2.0
  * @version $Revision$
  */
 public interface Synchronization {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java?rev=773801&r1=773800&r2=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java Tue May 12 06:45:01 2009
@@ -54,4 +54,11 @@
      * @return the unique ID
      */
     String getId();
+
+    /**
+     * Gets the original {@link org.apache.camel.Exchange} this Unit of Work was started with.
+     *
+     * @return the original exchange
+     */
+    Exchange getOriginalExchange();
 }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeTest.java?rev=773801&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeTest.java Tue May 12 06:45:01 2009
@@ -0,0 +1,87 @@
+/**
+ * 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.DeadLetterChannelBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test for useOriginalExchange option on DeadLetterChannel
+ *
+ * @version $Revision$
+ */
+public class DeadLetterChannelUseOriginalExchangeTest extends ContextTestSupport {
+
+    public void testUseOriginalExchange() throws Exception {
+        MockEndpoint dead = getMockEndpoint("mock:a");
+        dead.expectedBodiesReceived("Hello");
+
+        template.sendBody("direct:a", "Hello");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testDoNotUseOriginalExchange() throws Exception {
+        MockEndpoint dead = getMockEndpoint("mock:b");
+        dead.expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:b", "Hello");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // will use original
+                DeadLetterChannelBuilder a = deadLetterChannel("mock:a")
+                    .maximumRedeliveries(2).delay(0).logStackTrace(false).useOriginalExchange().handled(true);
+
+                // will NOT use original
+                DeadLetterChannelBuilder b = deadLetterChannel("mock:b")
+                    .maximumRedeliveries(2).delay(0).logStackTrace(false).handled(true);
+
+                from("direct:a")
+                    .errorHandler(a)
+                    .setBody(body().append(" World"))
+                    .process(new MyThrowProcessor());
+
+                from("direct:b")
+                    .errorHandler(b)
+                    .setBody(body().append(" World"))
+                    .process(new MyThrowProcessor());
+            }
+        };
+    }
+
+    public static class MyThrowProcessor implements Processor {
+
+        public MyThrowProcessor() {
+        }
+
+        public void process(Exchange exchange) throws Exception {
+            assertEquals("Hello World", exchange.getIn().getBody(String.class));
+            throw new IllegalArgumentException("Forced");
+        }
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeWithFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeWithFileTest.java?rev=773801&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeWithFileTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeWithFileTest.java Tue May 12 06:45:01 2009
@@ -0,0 +1,73 @@
+/**
+ * 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;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class DeadLetterChannelUseOriginalExchangeWithFileTest extends ContextTestSupport {
+
+    public void testOriginalExchangeIsFile() throws Exception {
+        MockEndpoint dead = getMockEndpoint("mock:dead");
+        dead.expectedMessageCount(1);
+        dead.message(0).body().isInstanceOf(GenericFile.class);
+        dead.message(0).bodyAs(String.class).isEqualTo("Hello");
+
+        template.sendBodyAndHeader("file://target/originalexchange", "Hello", Exchange.FILE_NAME, "hello.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        deleteDirectory("target/originalexchange");
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead").disableRedelivery().logStackTrace(false).useOriginalExchange().handled(true));
+
+                from("file://target/originalexchange")
+                    .transform(body().append(" World"))
+                    .process(new MyThrowProcessor());
+            }
+        };
+    }
+
+    public static class MyThrowProcessor implements Processor {
+
+        public MyThrowProcessor() {
+        }
+
+        public void process(Exchange exchange) throws Exception {
+            assertEquals("Hello World", exchange.getIn().getBody(String.class));
+            throw new IllegalArgumentException("Forced");
+        }
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeWithFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelUseOriginalExchangeWithFileTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceUseOriginalExchangeTest.java (from r773474, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceUseOriginalExchangeTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceUseOriginalExchangeTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java&r1=773474&r2=773801&rev=773801&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceUseOriginalExchangeTest.java Tue May 12 06:45:01 2009
@@ -24,7 +24,7 @@
 /**
  * Unit test for CAMEL-1188
  */
-public class OnExceptionFromChoiceTest extends ContextTestSupport {
+public class OnExceptionFromChoiceUseOriginalExchangeTest extends ContextTestSupport {
 
     private MyServiceBean myServiceBean;
 
@@ -37,7 +37,7 @@
         MockEndpoint mock = getMockEndpoint("mock:when");
         mock.expectedMessageCount(1);
 
-        template.sendBody("direct:start", "<order><type>myType</type><user>James</user></order>");
+        template.sendBody("direct:route", "<order><type>myType</type><user>James</user></order>");
 
         assertMockEndpointsSatisfied();
     }
@@ -49,9 +49,9 @@
         getMockEndpoint("mock:otherwise").expectedMessageCount(0);
 
         MockEndpoint mock = getMockEndpoint("mock:func");
-        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Func");
 
-        template.sendBody("direct:start", "<order><type>myType</type><user>Func</user></order>");
+        template.sendBody("direct:func", "Func");
 
         assertMockEndpointsSatisfied();
     }
@@ -63,9 +63,9 @@
         getMockEndpoint("mock:otherwise").expectedMessageCount(0);
 
         MockEndpoint mock = getMockEndpoint("mock:tech");
-        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Tech");
 
-        template.sendBody("direct:start", "<order><type>myType</type><user>Tech</user></order>");
+        template.sendBody("direct:tech", "Tech");
 
         assertMockEndpointsSatisfied();
     }
@@ -90,10 +90,19 @@
             public void configure() throws Exception {
                 errorHandler(deadLetterChannel("mock:error"));
 
-                onException(MyTechnicalException.class).maximumRedeliveries(0).handled(true).to("mock:tech");
-                onException(MyFunctionalException.class).maximumRedeliveries(0).handled(true).to("mock:func");
+                onException(MyTechnicalException.class).useOriginalExchange().maximumRedeliveries(0).handled(true).to("mock:tech");
+                onException(MyFunctionalException.class).useOriginalExchange().maximumRedeliveries(0).handled(true).to("mock:func");
+
+                from("direct:tech")
+                    .setBody(constant("<order><type>myType</type><user>Tech</user></order>"))
+                    .to("direct:route");
+
+                from("direct:func")
+                    .setBody(constant("<order><type>myType</type><user>Func</user></order>"))
+                    .to("direct:route");
+
 
-                from("direct:start")
+                from("direct:route")
                     .choice()
                         .when(bean("myServiceBean").isEqualTo("James")).to("mock:when")
                     .otherwise()

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionUseOriginalExchangeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionUseOriginalExchangeTest.java?rev=773801&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionUseOriginalExchangeTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionUseOriginalExchangeTest.java Tue May 12 06:45:01 2009
@@ -0,0 +1,110 @@
+/**
+ * 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.onexception;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test for useOriginalExchange option on DeadLetterChannel
+ *
+ * @version $Revision$
+ */
+public class OnExceptionUseOriginalExchangeTest extends ContextTestSupport {
+
+    public void testUseOriginalExchange() throws Exception {
+        MockEndpoint dead = getMockEndpoint("mock:a");
+        dead.expectedBodiesReceived("Hello");
+
+        template.sendBody("direct:a", "Hello");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testDoNotUseOriginalExchange() throws Exception {
+        MockEndpoint dead = getMockEndpoint("mock:dead");
+        dead.expectedBodiesReceived("Hello World");
+
+        try {
+            template.sendBody("direct:b", "Hello");
+            fail("Should have thrown an exception");
+        } catch (CamelExecutionException e) {
+            assertTrue(e.getCause().getMessage().startsWith("I cannot do it"));
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // will not use original exchange
+                errorHandler(deadLetterChannel("mock:dead").disableRedelivery().logStackTrace(false).delay(0));
+
+                // will use original exchange
+                onException(IllegalArgumentException.class)
+                    .maximumRedeliveries(2).useOriginalExchange().handled(true)
+                    .to("mock:a");
+
+                from("direct:a")
+                    .setBody(body().append(" World"))
+                    .process(new MyThrowProcessor(false));
+
+                from("direct:b")
+                    .setBody(body().append(" World"))
+                    .process(new MyThrowProcessor(true));
+            }
+        };
+    }
+
+    public static class MyThrowProcessor implements Processor {
+
+        private boolean camelException;
+
+        public MyThrowProcessor() {
+        }
+
+        public MyThrowProcessor(boolean camelException) {
+            this.camelException = camelException;
+        }
+
+        public void process(Exchange exchange) throws Exception {
+            assertEquals("Hello World", exchange.getIn().getBody(String.class));
+            if (camelException) {
+                throw new CamelExchangeException("I cannot do it", exchange);
+            } else {
+                throw new IllegalArgumentException("Forced");
+            }
+        }
+
+        public boolean isCamelException() {
+            return camelException;
+        }
+
+        public void setCamelException(boolean camelException) {
+            this.camelException = camelException;
+        }
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.java?rev=773801&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.java Tue May 12 06:45:01 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.DeadLetterChannelUseOriginalExchangeTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringDeadLetterChannelUseOriginalExchangeTest extends DeadLetterChannelUseOriginalExchangeTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.xml");
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.java?rev=773801&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.java Tue May 12 06:45:01 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.DeadLetterChannelUseOriginalExchangeWithFileTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringDeadLetterChannelUseOriginalExchangeWithFileTest extends DeadLetterChannelUseOriginalExchangeWithFileTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.java?rev=773801&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.java Tue May 12 06:45:01 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.spring.processor.onexception;
+
+import org.apache.camel.processor.onexception.OnExceptionFromChoiceUseOriginalExchangeTest;
+import org.apache.camel.CamelContext;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringOnExceptionFromChoiceUseOriginalExchangeTest extends OnExceptionFromChoiceUseOriginalExchangeTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.xml");
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.java?rev=773801&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.java Tue May 12 06:45:01 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.spring.processor.onexception;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.onexception.OnExceptionUseOriginalExchangeTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringOnExceptionUseOriginalExchangeTest extends OnExceptionUseOriginalExchangeTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.xml (from r773783, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml&r1=773783&r2=773801&rev=773801&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeTest.xml Tue May 12 06:45:01 2009
@@ -23,12 +23,14 @@
     ">
 
     <!-- START SNIPPET: e1 -->
-    <bean id="myDLC" class="org.apache.camel.builder.DeadLetterChannelBuilder">
-        <!-- move failed messages to the mock:dead dead letter queue -->
-        <property name="deadLetterUri" value="mock:dead"/>
+    <bean id="a" class="org.apache.camel.builder.DeadLetterChannelBuilder">
+        <!-- move failed messages to the mock:a dead letter queue -->
+        <property name="deadLetterUri" value="mock:a"/>
         <!-- we mark all exchanges as handled when they are moved to the dead letter queue, so the client
              does not receive an exception -->
         <property name="handled" value="true"/>
+        <!-- use the original exchange when moving to dead letter queue -->
+        <property name="useOriginalExchange" value="true"/>
         <property name="redeliveryPolicy" ref="myRedelivery"/>
     </bean>
 
@@ -39,11 +41,29 @@
     </bean>
     <!-- END SNIPPET: e1 -->
 
-    <bean id="myThrowProcessor" class="org.apache.camel.processor.DeadLetterChannelHandledPolicyTest$MyThrowExceptionProcessor"/>
+    <bean id="b" class="org.apache.camel.builder.DeadLetterChannelBuilder">
+        <!-- move failed messages to the mock:b dead letter queue -->
+        <property name="deadLetterUri" value="mock:b"/>
+        <!-- we mark all exchanges as handled when they are moved to the dead letter queue, so the client
+             does not receive an exception -->
+        <property name="handled" value="true"/>
+        <!-- do NOT use the original exchange when moving to dead letter queue -->
+        <property name="useOriginalExchange" value="false"/>
+        <property name="redeliveryPolicy" ref="myRedelivery"/>
+    </bean>
+
+    <bean id="myThrowProcessor" class="org.apache.camel.processor.DeadLetterChannelUseOriginalExchangeTest$MyThrowProcessor"/>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route errorHandlerRef="a">
+            <from uri="direct:a"/>
+            <setBody><simple>${in.body} World</simple></setBody>
+            <process ref="myThrowProcessor"/>
+        </route>
 
-    <camelContext id="camel" errorHandlerRef="myDLC" xmlns="http://camel.apache.org/schema/spring">
-        <route>
-            <from uri="direct:start"/>
+        <route errorHandlerRef="b">
+            <from uri="direct:b"/>
+            <setBody><simple>${in.body} World</simple></setBody>
             <process ref="myThrowProcessor"/>
         </route>
     </camelContext>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml?rev=773801&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml Tue May 12 06:45:01 2009
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: e1 -->
+    <bean id="dead" class="org.apache.camel.builder.DeadLetterChannelBuilder">
+        <!-- move failed messages to the mock:dead dead letter queue -->
+        <property name="deadLetterUri" value="mock:dead"/>
+        <!-- we mark all exchanges as handled when they are moved to the dead letter queue, so the client
+             does not receive an exception -->
+        <property name="handled" value="true"/>
+        <!-- use the original exchange when moving to dead letter queue -->
+        <property name="useOriginalExchange" value="true"/>
+        <property name="redeliveryPolicy" ref="myRedelivery"/>
+    </bean>
+
+    <bean id="myRedelivery" class="org.apache.camel.processor.RedeliveryPolicy">
+        <property name="maximumRedeliveries" value="0"/>
+        <property name="delay" value="0"/>
+        <property name="logStackTrace" value="false"/>
+    </bean>
+    <!-- END SNIPPET: e1 -->
+
+    <bean id="b" class="org.apache.camel.builder.DeadLetterChannelBuilder">
+        <!-- move failed messages to the mock:b dead letter queue -->
+        <property name="deadLetterUri" value="mock:b"/>
+        <!-- we mark all exchanges as handled when they are moved to the dead letter queue, so the client
+             does not receive an exception -->
+        <property name="handled" value="true"/>
+        <!-- do NOT use the original exchange when moving to dead letter queue -->
+        <property name="useOriginalExchange" value="false"/>
+        <property name="redeliveryPolicy" ref="myRedelivery"/>
+    </bean>
+
+
+    <bean id="myThrowProcessor" class="org.apache.camel.processor.DeadLetterChannelUseOriginalExchangeWithFileTest$MyThrowProcessor"/>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route errorHandlerRef="dead">
+            <from uri="file://target/originalexchange"/>
+            <setBody><simple>${in.body} World</simple></setBody>
+            <process ref="myThrowProcessor"/>
+        </route>
+    </camelContext>
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.xml (from r773783, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml&r1=773783&r2=773801&rev=773801&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalExchangeTest.xml Tue May 12 06:45:01 2009
@@ -22,44 +22,48 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- START SNIPPET: e1 -->
-    <!-- setup our error handler as the deal letter channel -->
     <bean id="deadLetter" class="org.apache.camel.builder.DeadLetterChannelBuilder">
-        <property name="deadLetterUri" value="mock:dead"/>
+        <property name="deadLetterUri" value="mock:error"/>
     </bean>
 
-    <!-- the default error handler used in the 2nd route -->
-    <bean id="defaultErrorHandler" class="org.apache.camel.builder.DefaultErrorHandlerBuilder"/>
+    <bean id="serviceBean" class="org.apache.camel.processor.onexception.MyServiceBean"/>
 
-    <!-- this is our POJO bean with our business logic defined as a plain spring bean -->
-    <bean id="orderService" class="org.apache.camel.spring.processor.onexception.OrderService"/>
+    <camelContext errorHandlerRef="deadLetter" xmlns="http://camel.apache.org/schema/spring">
 
-    <!-- this is the camel context where we define the routes -->
-    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <onException useOriginalExchange="true">
+            <exception>org.apache.camel.processor.onexception.MyTechnicalException</exception>
+            <redeliveryPolicy maximumRedeliveries="0" logStackTrace="false"/>
+            <handled><constant>true</constant></handled>
+            <to uri="mock:tech"/>
+        </onException>
+
+        <onException useOriginalExchange="true">
+            <exception>org.apache.camel.processor.onexception.MyFunctionalException</exception>
+            <redeliveryPolicy maximumRedeliveries="0" logStackTrace="false"/>
+            <handled><constant>true</constant></handled>
+            <to uri="mock:func"/>
+        </onException>
+
+        <route>
+            <from uri="direct:tech"/>
+            <setBody><constant>&lt;order&gt;&lt;type&gt;myType&lt;/type&gt;&lt;user&gt;Tech&lt;/user&gt;&lt;/order&gt;</constant></setBody>
+            <to uri="direct:route"/>
+        </route>
 
-        <route errorHandlerRef="deadLetter">
-            <from uri="direct:start"/>
-            <onException>
-                <exception>org.apache.camel.spring.processor.onexception.OrderFailedException</exception>
-                <redeliveryPolicy maximumRedeliveries="1"/>
-                <handled>
-                    <constant>true</constant>
-                </handled>
-                <bean ref="orderService" method="orderFailed"/>
-                <to uri="mock:error"/>
-            </onException>
-            <bean ref="orderService" method="handleOrder"/>
-            <to uri="mock:result"/>
+        <route>
+            <from uri="direct:func"/>
+            <setBody><constant>&lt;order&gt;&lt;type&gt;myType&lt;/type&gt;&lt;user&gt;Func&lt;/user&gt;&lt;/order&gt;</constant></setBody>
+            <to uri="direct:route"/>
         </route>
 
-        <!-- The exception clause specified in the first route will not be used in this route -->
-        <route errorHandlerRef="defaultErrorHandler">
-            <from uri="direct:start_with_no_handler"/>
-            <bean ref="orderService" method="handleOrder"/>
-            <to uri="mock:result"/>
+        <route>
+            <from uri="direct:route"/>
+            <choice>
+                <when><simple>${bean:serviceBean} == 'James'</simple><to uri="mock:when"/></when>
+                <otherwise><to uri="mock:otherwise"/></otherwise>
+            </choice>
         </route>
 
     </camelContext>
-    <!-- END SNIPPET: e1 -->
 
 </beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml?rev=773801&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml Tue May 12 06:45:01 2009
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="deadLetter" class="org.apache.camel.builder.DeadLetterChannelBuilder">
+        <property name="deadLetterUri" value="mock:dead"/>
+        <property name="redeliveryPolicy" ref="myRedeliveryPolicy"/>
+    </bean>
+
+    <bean id="myRedeliveryPolicy" class="org.apache.camel.processor.RedeliveryPolicy">
+        <property name="delay" value="0"/>
+        <property name="logStackTrace" value="false"/>
+        <property name="maximumRedeliveries" value="0"/>
+    </bean>
+
+    <bean id="procA" class="org.apache.camel.processor.onexception.OnExceptionUseOriginalExchangeTest$MyThrowProcessor">
+        <property name="camelException" value="false"/>
+    </bean>
+
+    <bean id="procB" class="org.apache.camel.processor.onexception.OnExceptionUseOriginalExchangeTest$MyThrowProcessor">
+        <property name="camelException" value="true"/>
+    </bean>
+
+    <camelContext errorHandlerRef="deadLetter" xmlns="http://camel.apache.org/schema/spring">
+
+        <onException useOriginalExchange="true">
+            <exception>java.lang.IllegalArgumentException</exception>
+            <redeliveryPolicy maximumRedeliveries="2"/>
+            <handled><constant>true</constant></handled>
+            <to uri="mock:a"/>
+        </onException>
+
+        <route>
+            <from uri="direct:a"/>
+            <setBody><simple>${in.body} World</simple></setBody>
+            <process ref="procA"/>
+        </route>
+
+        <route>
+            <from uri="direct:b"/>
+            <setBody><simple>${in.body} World</simple></setBody>
+            <process ref="procB"/>
+        </route>
+
+    </camelContext>
+
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/SpringOnExceptionUseOriginalExchangeTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message