You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by wing-tung Leung <wi...@gmail.com> on 2011/08/08 15:13:41 UTC

Enter multiple onException clauses in a single route?

I have a route where I perform some XSD validation first, and after
that a HTTP download. The XSD validation is "optional", meaning that
failure is simply logged but should not block the rest of the flow,
while HTTP download exceptions should abort.

I have defined two separate "onException" blocks, one for the
"ValidationException" with "continued" enabled, and another for the
"HttpOperationFailedException". They both seem to work fine
independently, but for some reason, capturing both exceptions is not
possible.

Initially, I assumed that after the "silent" handling of
ValidationException, the second exception (HTTP)  handler would kick
in, but it's never called. Is this because only 1 "onException"
handler can be called per route?

Wrapping the first XSD check into a explicit doTry/doCatch does work
like I expected ..

Someone some suggestion how to implement this best?

Many thanks!

Tung

Re: Enter multiple onException clauses in a single route?

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 8, 2011 at 3:46 PM, wing-tung Leung
<wi...@gmail.com> wrote:
> On Mon, Aug 8, 2011 at 3:27 PM, Claus Ibsen <cl...@gmail.com> wrote:
>> On Mon, Aug 8, 2011 at 3:13 PM, wing-tung Leung
>> <wi...@gmail.com> wrote:
>>> I have a route where I perform some XSD validation first, and after
>>> that a HTTP download. The XSD validation is "optional", meaning that
>>> failure is simply logged but should not block the rest of the flow,
>>> while HTTP download exceptions should abort.
>
> [snip]
>
>>> Initially, I assumed that after the "silent" handling of
>>> ValidationException, the second exception (HTTP)  handler would kick
>>> in, but it's never called. Is this because only 1 "onException"
>>> handler can be called per route?
>
> [snip]
>
>> What version of Camel are you using?
>
> Well, the not so new version 2.6.0, because we are currently still
> stuck to JDK 1.5.  :-(
>
> I'm willing to try with a more recent version, but this involves a big
> bunch of local changes, and prefer to avoid it if not necessary ..
>

We fixed an issue with continued on the onException in a recent release.
I suggest to stick with try . catch in your Camel 2.6 release on JDK5.

-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Enter multiple onException clauses in a single route?

Posted by wing-tung Leung <wi...@gmail.com>.
On Mon, Aug 8, 2011 at 3:27 PM, Claus Ibsen <cl...@gmail.com> wrote:
> On Mon, Aug 8, 2011 at 3:13 PM, wing-tung Leung
> <wi...@gmail.com> wrote:
>> I have a route where I perform some XSD validation first, and after
>> that a HTTP download. The XSD validation is "optional", meaning that
>> failure is simply logged but should not block the rest of the flow,
>> while HTTP download exceptions should abort.

[snip]

>> Initially, I assumed that after the "silent" handling of
>> ValidationException, the second exception (HTTP)  handler would kick
>> in, but it's never called. Is this because only 1 "onException"
>> handler can be called per route?

[snip]

> What version of Camel are you using?

Well, the not so new version 2.6.0, because we are currently still
stuck to JDK 1.5.  :-(

I'm willing to try with a more recent version, but this involves a big
bunch of local changes, and prefer to avoid it if not necessary ..

Re: Enter multiple onException clauses in a single route?

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 8, 2011 at 3:13 PM, wing-tung Leung
<wi...@gmail.com> wrote:
> I have a route where I perform some XSD validation first, and after
> that a HTTP download. The XSD validation is "optional", meaning that
> failure is simply logged but should not block the rest of the flow,
> while HTTP download exceptions should abort.
>
> I have defined two separate "onException" blocks, one for the
> "ValidationException" with "continued" enabled, and another for the
> "HttpOperationFailedException". They both seem to work fine
> independently, but for some reason, capturing both exceptions is not
> possible.
>
> Initially, I assumed that after the "silent" handling of
> ValidationException, the second exception (HTTP)  handler would kick
> in, but it's never called. Is this because only 1 "onException"
> handler can be called per route?
>
> Wrapping the first XSD check into a explicit doTry/doCatch does work
> like I expected ..
>
> Someone some suggestion how to implement this best?
>

What version of Camel are you using?


> Many thanks!
>
> Tung
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/