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: try / catch vs onException
Date Tue, 09 Dec 2008 12:55:28 GMT
Hi

The try .. catch to my knowledge is a mirror of the try ... catch
concept in Java.
So when you use catch the exception is *handled* and you have to deal
what should happen now.


Yes the onException is a more general concept that is working together
with the error handler.
Using onException you can use fine grained control how this particular
exception is seen by the error handler.

You can
- adjust re deliveries settings: such as number of retries, delays
etc. etc. that overrule the settings on error handler
- route them differently, take a detour to log it, send an email etc.
- and even in 1.5 you can mark it as handled so there is no exception
and you can return a different response to the caller

For instance you can use onException to say all
java.io.ConnectException should use 10 sec delay, and retry 10 times.
However all xxxException should not redeliver etc. etc.

That is my understanding of it.

Ramon great that you are digging into this and raising questions. This
is also how I got started on Camel. I was to curious how this animal
worked inside. And being able to contribute patches. We love 'em



/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/



On Tue, Dec 9, 2008 at 4:13 AM, Ramon Buckland <ramon@thebuckland.com> wrote:
> Hi All,
>
> I have a user question regarding the differences between try / catch and
> onException
>
> In sample documentation you find the use of
>
>   <try>
>
>        <to ../>
>
>        <catch>
>             <exception>foo.Exception</exception>
>             .. handle ..
>        </catch>
>   </try>
>
> My question is, what are the logical differences between this and
> <onException ..> and why would you use either ?
>
> I ask this as I have a found two potential bugs, to which I want to provide
> a correct patch for also (a "forced learn the code" task) but want to first
> understand what each path is designed for.
>
> *I suspect the onException will have something to do with managing
> redeliveries etc.
>
> *Logging the bugs shortly.*
>            [File poller throwing exception is not caught by onException
> "before any messages are sent"]  Use an Access Denial on a file (list but
> not read, windows readlock etc)
>            [File poller does not "start" if wrapped in a <try> <catch>] *Are
> there other endpoints that suffer the same, or is it incorrect use?
> *
> **
> *cheers
> r.
>

Mime
View raw message