camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" <>
Subject Re: 1.5 error handling Spring config buggy/not complete?
Date Thu, 20 Nov 2008 17:10:48 GMT

#1 + #2
Yeah you have a use case that is a bit more advanced. I have created a
ticket to make it easier to attach a predicate to the onException so
you can do your custom test here also before the onexception is

You could however write your own customized exception policy strategy:

Camel has a default strategy that is used to find the matching
exception thrown in the list of onException tags.

There is a sample on the link above. Basically what you have to do is
to find the matching onException to use from the given map of
exception types. The last parameter is the actual exception thrown.

So if the last exception is your special exception you can do the enum
test and find the correct onException from the map, and return it.

I am afraid the sample is for Java DSL so you could try to see if you
can get it to work in Spring DSL as well. Let me know how it goes.

/Claus Ibsen
Apache Camel Committer

On Thu, Nov 20, 2008 at 3:40 PM, Fush <> wrote:
> Yeah, I've now moved the onException to right after the <from> tag. It looks
> like this:
> <onException>
>        <exception></exception>
>        <redeliveryPolicy maximumRedeliveries="0" />
>        <choice>
>                <when>
>                        <methodCall bean="myOwnErrorHandler" method="hasSpecialEnumCode"/>
>                        <handled>
>                                <constant>true</constant>
>                        </handled>
>                        <to uri="activemq:queue/myQueue/myFunctionalErrorQueue"/>
>                </when>
>                <otherwise/>
>        </choice>
> </onException>
> But there are two problems with this:
> 1. The <handled> tag can't be inside the <when> tags.
> 2. If the <methodCall> resolves to false (ie the special enum is not found,
> and the <otherwise> tag is entered), I would like the normal
> redeliveryPolicy set on the jmsConnectionFactory to kick in and handle the
> exception (ie with delay/redeliveries). But with the present configuration,
> it seems like I must implement some error handling within the <otherwise>,
> right?
> Claus Ibsen-2 wrote:
>> Hi
>> Could you try to move the onException outside the from tag?
>> It should be like this:
>> <route>
>>    <onException>
>>    </onException
>>    <from>
>>     ...
>> </route>
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

View raw message