Hi

Yeah error handling and redelivery is hard.

1)
onRedelivery is *only* executed when Camel performs a redelivery
attempt. That is it retries processing some exchange that failed last
time.

2)
onException will by default not do any redelivery attempts, unless you
set a maximumRedelivers option >= 1.

So in your first attempt Camel will by the onException catch the
RuntimeException and *not do any redeliveries* as maximumRedelivers is
by default = 0 for onException.

So when you change the maximumRedeliveries = 1 then the onRedelivery
processor kicks in as expected.
onRedelivery is meant to allow you to do a bit of custom message
adjustment before Camel retries. And yes it can also be used for
logging.





On Wed, May 27, 2009 at 4:32 PM, mta38 <[email protected]> wrote:
>
> Hi all,
>
> I play with Exception, ErrorHandler and redelivery (Camel 2.0-M1) and there
> are some things  that I can't understand :confused:.
>
> snippet code
>
> <bean id="globalDeadLetterChannel"
> class="org.apache.camel.builder.DeadLetterChannelBuilder">
>         <property name="defaultDeadLetterEndpointUri"
> value="direct:response"/>
>    <property name="onRedelivery" ref="routeRedelivery"/>
>          <property name="redeliveryPolicy">
>                <bean id="redeliveryPolicyConfig"
> class="org.apache.camel.processor.RedeliveryPolicy">
>                         <property name="maximumRedeliveries" value="1"/>
>                </bean>
>         </property>
>         </bean>
>
> <camelContext  id="camelContext"  errorHandlerRef="globalDeadLetterChannel"
> xmlns="http://camel.apache.org/schema/spring";>
>
>                <onException >
>                        <exception>java.lang.RuntimeException</exception>
>                        <handled>
>                                <constant>true</constant>
>                        </handled>
>                        <to uri="direct:response" />
>                </onException>
>
> … other routes …
>
> </camelContext>
>
> routeRedelivery bean is a processor which make some trace  in a log file.
>
> When I raise a runtimeException, the process method of routeRedelivery bean
> is not called. I can't understand why, since onRedelivery property is
> defined for my global dead letter channel.
>
> If I modify onException element like following:
>
>
> <onException onRedeliveryRef="routeRedelivery">
> <exception>java.lang.RuntimeException</exception>
>        <redeliveryPolicy maximumRedeliveries="1"/>
>        <handled>
>                <constant>true</constant>
>        </handled>
>        <to uri="direct:response" />
> </onException>
>
>
> And I raised a RuntimeException, I have some trace in my log file that
> proves that process method of routeRedelivery bean is called.
>
> Is someone can explain me why onRedelivery processor is not called when it's
> defined in global scope will be appreciated.
> Best regards,
> Mta38
>
> --
> View this message in context: 
> http://www.nabble.com/Exception%2C-ErrorHandler-and-redelivery-tp23743717p23743717.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to