camel-users mailing list archives

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

#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
triggered.
http://issues.apache.org/activemq/browse/CAMEL-1104

You could however write your own customized exception policy strategy:
http://activemq.apache.org/camel/error-handler.html

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
Blog: http://davsclaus.blogspot.com/



On Thu, Nov 20, 2008 at 3:40 PM, Fush <rikard.eriksen@gmail.com> wrote:
>
> Yeah, I've now moved the onException to right after the <from> tag. It looks
> like this:
>
> <onException>
>        <exception>org.my.exception.FunctionalException</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: http://www.nabble.com/1.5-error-handling-Spring-config-buggy-not-complete--tp20562554s22882p20602491.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message