camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r773507 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/java/org/apache/camel/util/ camel-core/src/test/java/org/apache/camel/processor/ componen...
Date Mon, 11 May 2009 09:29:17 GMT
Author: davsclaus
Date: Mon May 11 09:29:16 2009
New Revision: 773507

URL: http://svn.apache.org/viewvc?rev=773507&view=rev
Log:
CAMEL-1598: Added handled option to DeadLetterChannel so we have this one here also like onException.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml
      - copied, changed from r773474, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.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/processor/DeadLetterChannel.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.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=773507&r1=773506&r2=773507&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
Mon May 11 09:29:16 2009
@@ -20,6 +20,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.LoggingLevel;
+import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.processor.DeadLetterChannel;
 import org.apache.camel.processor.ErrorHandlerSupport;
@@ -31,6 +32,7 @@
 import org.apache.camel.spi.RouteContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import static org.apache.camel.builder.PredicateBuilder.toPredicate;
 
 /**
  * A builder of a <a
@@ -47,6 +49,7 @@
     private Processor failureProcessor;
     private Endpoint deadLetter;
     private String deadLetterUri;
+    private Predicate handledPolicy;
 
     /**
      * Creates a default DeadLetterChannel with a default endpoint
@@ -74,7 +77,8 @@
     }
 
     public Processor createErrorHandler(RouteContext routeContext, Processor processor) throws
Exception {
-        DeadLetterChannel answer = new DeadLetterChannel(processor, getFailureProcessor(),
deadLetterUri, onRedelivery, getRedeliveryPolicy(), getLogger(), getExceptionPolicyStrategy());
+        DeadLetterChannel answer = new DeadLetterChannel(processor, getFailureProcessor(),
deadLetterUri, onRedelivery,
+                getRedeliveryPolicy(), getLogger(), getExceptionPolicyStrategy(), getHandledPolicy());
         // must enable stream cache as DeadLetterChannel can do redeliveries and
         // thus it needs to be able to read the stream again
         configure(answer);
@@ -148,6 +152,39 @@
     }
 
     /**
+     * Sets whether the exchange should be marked as handled or not.
+     *
+     * @param handled  handled or not
+     * @return the builder
+     */
+    public DeadLetterChannelBuilder handled(boolean handled) {
+        Expression expression = ExpressionBuilder.constantExpression(Boolean.toString(handled));
+        return handled(expression);
+    }
+
+    /**
+     * Sets whether the exchange should be marked as handled or not.
+     *
+     * @param handled  predicate that determines true or false
+     * @return the builder
+     */
+    public DeadLetterChannelBuilder handled(Predicate handled) {
+        this.setHandledPolicy(handled);
+        return this;
+    }
+
+    /**
+     * Sets whether the exchange should be marked as handled or not.
+     *
+     * @param handled  expression that determines true or false
+     * @return the builder
+     */
+    public DeadLetterChannelBuilder handled(Expression handled) {
+        this.setHandledPolicy(toPredicate(handled));
+        return this;
+    }
+
+    /**
      * Sets the logger used for caught exceptions
      */
     public DeadLetterChannelBuilder logger(Logger logger) {
@@ -226,6 +263,10 @@
         return failureProcessor;
     }
 
+    public void setFailureProcessor(Processor failureProcessor) {
+        this.failureProcessor = failureProcessor;
+    }
+
     public String getDeadLetterUri() {
         return deadLetterUri;
     }
@@ -283,6 +324,21 @@
         this.onRedelivery = onRedelivery;
     }
 
+    public Predicate getHandledPolicy() {
+        return handledPolicy;
+    }
+
+    public void setHandledPolicy(Predicate handled) {
+        this.handledPolicy = handled;
+    }
+
+    /**
+     * Sets the handled using a boolean and thus easier to use for Spring XML configuration
as well
+     */
+    public void setHandled(boolean handled) {
+        handled(handled);
+    }
+
     @Override
     public String toString() {
         return "DeadLetterChannelBuilder(" + deadLetterUri + ")";

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=773507&r1=773506&r2=773507&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
Mon May 11 09:29:16 2009
@@ -47,27 +47,26 @@
     // or not. Also consider MEP as InOut does not work with async then as the original caller
thread
     // is expecting a reply in the sync thread.
 
-    // TODO: DLQ should handle by default, so added option to set global predicate on DLC
-
     // we can use a single shared static timer for async redeliveries
     private final Processor deadLetter;
     private final String deadLetterUri;
     private final Processor output;
     private final Processor redeliveryProcessor;
-    private RedeliveryPolicy redeliveryPolicy;
+    private final RedeliveryPolicy redeliveryPolicy;
+    private final Predicate handledPolicy;
     private Logger logger;
 
     private class RedeliveryData {
         int redeliveryCounter;
         long redeliveryDelay;
         boolean sync = true;
-        Predicate handledPredicate;
         Predicate retryUntilPredicate;
 
         // default behavior which can be overloaded on a per exception basis
         RedeliveryPolicy currentRedeliveryPolicy = redeliveryPolicy;
         Processor deadLetterQueue = deadLetter;
         Processor onRedeliveryProcessor = redeliveryProcessor;
+        Predicate handledPredicate = handledPolicy;
     }
     
     /**
@@ -80,15 +79,18 @@
      * @param redeliveryPolicy          policy for redelivery
      * @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
      */
     public DeadLetterChannel(Processor output, Processor deadLetter, String deadLetterUri,
Processor redeliveryProcessor,
-                             RedeliveryPolicy redeliveryPolicy, Logger logger, ExceptionPolicyStrategy
exceptionPolicyStrategy) {
+                             RedeliveryPolicy redeliveryPolicy, Logger logger, ExceptionPolicyStrategy
exceptionPolicyStrategy,
+                             Predicate handledPolicy) {
         this.output = output;
         this.deadLetter = deadLetter;
         this.deadLetterUri = deadLetterUri;
         this.redeliveryProcessor = redeliveryProcessor;
         this.redeliveryPolicy = redeliveryPolicy;
         this.logger = logger;
+        this.handledPolicy = handledPolicy;
         setExceptionPolicy(exceptionPolicyStrategy);
     }
 
@@ -202,13 +204,6 @@
         return redeliveryPolicy;
     }
 
-    /**
-     * Sets the redelivery policy
-     */
-    public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy) {
-        this.redeliveryPolicy = redeliveryPolicy;
-    }
-
     public Logger getLogger() {
         return logger;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java?rev=773507&r1=773506&r2=773507&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java Mon May
11 09:29:16 2009
@@ -478,6 +478,11 @@
         } catch (ExecutionException e) {
             // execution failed due to an exception so rethrow the cause
             throw ObjectHelper.wrapCamelExecutionException(null, e.getCause());
+        } finally {
+            // its harmless to cancel if task is already completed
+            // and in any case we do not want to get hold of the task a 2nd time
+            // and its recommended to cancel according to Brian Goetz in his Java Concurrency
in Practice book
+            future.cancel(true);
         }
     }
 
@@ -507,6 +512,11 @@
         } catch (ExecutionException e) {
             // execution failed due to an exception so rethrow the cause
             throw ObjectHelper.wrapCamelExecutionException(null, e.getCause());
+        } finally {
+            // its harmless to cancel if task is already completed
+            // and in any case we do not want to get hold of the task a 2nd time
+            // and its recommended to cancel according to Brian Goetz in his Java Concurrency
in Practice book
+            future.cancel(true);
         }
     }
 

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java?rev=773507&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
Mon May 11 09:29:16 2009
@@ -0,0 +1,89 @@
+/**
+ * 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.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * DeadLetterChannel now also have handled policy, like onException.
+ *
+ * @version $Revision$
+ */
+public class DeadLetterChannelHandledPolicyTest extends ContextTestSupport {
+
+    public void testHandled() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead").maximumRedeliveries(1).delay(0).logStackTrace(false).handled(true));
+
+                from("direct:start")
+                    .process(new MyThrowExceptionProcessor());
+            }
+        });
+        context.start();
+
+        getMockEndpoint("mock:dead").expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:start", "Hello World");
+
+        // as its handled no exception is thrown to the client
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testNotHandled() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead").maximumRedeliveries(1).delay(0).logStackTrace(false).handled(false));
+
+                from("direct:start")
+                    .process(new MyThrowExceptionProcessor());
+            }
+        });
+        context.start();
+
+        getMockEndpoint("mock:dead").expectedBodiesReceived("Hello World");
+
+        try {
+            template.sendBody("direct:start", "Hello World");
+            fail("Should have thrown an exception");
+        } catch (CamelExecutionException e) {
+            // as its NOT handled the exception should be thrown back to the client
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("Forced", e.getCause().getMessage());
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    // for spring unit testing
+    public static class MyThrowExceptionProcessor implements Processor {
+
+        public MyThrowExceptionProcessor() {
+        }
+
+        public void process(Exchange exchange) throws Exception {
+            throw new IllegalArgumentException("Forced");
+        }
+    }
+
+}

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

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

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.java?rev=773507&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.java
Mon May 11 09:29:16 2009
@@ -0,0 +1,41 @@
+/**
+ * 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.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringDeadLetterChannelHandledPolicyTest extends SpringTestSupport {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml");
+    }
+
+    public void testHandled() throws Exception {
+        getMockEndpoint("mock:dead").expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:start", "Hello World");
+
+        // as its handled no exception is thrown to the client
+        assertMockEndpointsSatisfied();
+    }
+
+}

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

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

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.java?rev=773507&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.java
Mon May 11 09:29:16 2009
@@ -0,0 +1,48 @@
+/**
+ * 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.CamelExecutionException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringDeadLetterChannelNotHandledPolicyTest extends SpringTestSupport {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.xml");
+    }
+
+    public void testNotHandled() throws Exception {
+        getMockEndpoint("mock:dead").expectedBodiesReceived("Hello World");
+
+        try {
+            template.sendBody("direct:start", "Hello World");
+            fail("Should have thrown an exception");
+        } catch (CamelExecutionException e) {
+            // as its NOT handled the exception should be thrown back to the client
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("Forced", e.getCause().getMessage());
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+}
\ No newline at end of file

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

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

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml
(from r773474, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml&r1=773474&r2=773507&rev=773507&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml
Mon May 11 09:29:16 2009
@@ -22,35 +22,29 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- START SNIPPET: example -->
-    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+    <!-- 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"/>
+        <!-- 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"/>
+        <property name="redeliveryPolicy" ref="myRedelivery"/>
+    </bean>
+
+    <bean id="myRedelivery" class="org.apache.camel.processor.RedeliveryPolicy">
+        <property name="maximumRedeliveries" value="2"/>
+        <property name="delay" value="0"/>
+        <property name="logStackTrace" value="false"/>
+    </bean>
+    <!-- END SNIPPET: e1 -->
+
+    <bean id="myThrowProcessor" class="org.apache.camel.processor.DeadLetterChannelHandledPolicyTest$MyThrowExceptionProcessor"/>
+
+    <camelContext id="camel" errorHandlerRef="myDLC" xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="direct:start"/>
-            <choice>
-                <when><simple>${in.body} contains 'Hello'</simple>
-                    <to uri="mock:hello"/>
-                </when>
-                <when><simple>${in.body} contains 'Bye'</simple>
-                    <to uri="mock:bye"/>
-                    <!-- here we stop continue routing so this was the last processing
step -->
-                    <stop/>
-                </when>
-                <otherwise>
-                    <to uri="mock:other"/>
-                </otherwise>
-            </choice>
-            <to uri="mock:result"/>
-        </route>
-        
-        <route>
-            <from uri="direct:foo"/>
-            <to uri="mock:foo"/>
-            <!-- you can also set the Exchange#ROUTE_STOP property on Exchange to true
-->
-            <setProperty propertyName="CamelRouteStop">
-                <constant>true</constant>
-            </setProperty>
-            <to uri="mock:result"/>
+            <process ref="myThrowProcessor"/>
         </route>
     </camelContext>
-    <!-- END SNIPPET: example -->
 </beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.xml?rev=773507&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.xml
(added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.xml
Mon May 11 09:29:16 2009
@@ -0,0 +1,50 @@
+<?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="myDLC" 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 NOT handled when they are moved to the dead letter
queue, so the client
+             wil receive the caused exception (this is also the default behaviour) -->
+        <property name="handled" value="false"/>
+        <property name="redeliveryPolicy" ref="myRedelivery"/>
+    </bean>
+
+    <bean id="myRedelivery" class="org.apache.camel.processor.RedeliveryPolicy">
+        <property name="maximumRedeliveries" value="2"/>
+        <property name="delay" value="0"/>
+        <property name="logStackTrace" value="false"/>
+    </bean>
+    <!-- END SNIPPET: e1 -->
+
+    <bean id="myThrowProcessor" class="org.apache.camel.processor.DeadLetterChannelHandledPolicyTest$MyThrowExceptionProcessor"/>
+
+    <camelContext id="camel" errorHandlerRef="myDLC" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <process ref="myThrowProcessor"/>
+        </route>
+    </camelContext>
+</beans>

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

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

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



Mime
View raw message