Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
    <bean id="myRedeliveryPolicy" class="org.apache.camel.processor.RedeliveryPolicy">
        <property name="maximumRedeliveries" value="${myprop.max}"/>
    </bean>

     <onException>
         <!-- you can define multiple exceptions just adding more exception elements as show below -->
         <exception>com.mycompany.MyFirstException</exception>
         <exception>com.mycompany.MySecondException</exception>

         <!-- here we reference our redelivy policy defined above -->
         <redeliveryPolicy ref="myRedeliveryPolicy"/>
     </onException>

Exception Policy Strategy

As of Camel 1.4 you can configure the ExceptionPolicyStrategy as this example shows. Notice that we use Exception Clause to handle known exceptions being thrown.

Wiki Markup
{snippet:id=e1|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/CustomExceptionPolicyStrategyTest.java}

Using our own strategy MyPolicy we can change the default behavior of Camel with our own code to resolve which ExceptionType from above should be handling the given thrown exception.

Wiki Markup
{snippet:id=e2|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/CustomExceptionPolicyStrategyTest.java}

Using the transactional error handler

...