You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Roman Kalukiewicz <ro...@gmail.com> on 2009/02/25 12:10:29 UTC

Where exception handling should set a handled exception?

Hello!

Recently I created an issue (CAMEL-1356) about exception handling and
now I'm not really sure if it is really a bug or not. So I'm asking
for your opinions.

The problem is that when exception is caught it is set as a
'caught.exception' header on IN message. It means that if an exception
is thrown on an exchange that already has OUT message it will be lost
after the first step of a pipeline.

We have few possible solutions here:
1) Keep it as it is - then we know where to look for this header in
the first step of the pipeline - we can also use bean integration and
@Header annotation to retrieve it)
2) Put the exception to header on OUT message if it is present - then
it will be preserved in the pipeline. But then first step of the
pipeline has to be clever - it has to look for it in OUT message.
Moreover it is more general problem - if we allow OUT messages there,
then you cannot use for example setHeader("foo") (you can, but it is
useless, as out is propagated anyway)
3) Put it into exchange property - maybe the best solution as it is
propagated, and we always know where to look for the exception. It
will not be lost at some endpoint also.

I believe this change should by put to 2.0 only as it might break
someones exception handling completely, shouldn't it?

This time I don't want to start flame about need for in/out messages
once again, but... ;)

Roman

Re: Where exception handling should set a handled exception?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi Roman

Could you add a route example to that.
AFAIR this is *only* with the try .. handle DSLs ?

I can enlighten that on the DeadLetterChannel we store previoysly
occured exception as a property when we do redelivery.
There is a constant KEY for it on the Exchange (Camel 2.0)

    String EXCEPTION_CAUGHT = "CamelExceptionCaught";



On Wed, Feb 25, 2009 at 12:10 PM, Roman Kalukiewicz
<ro...@gmail.com> wrote:
> Hello!
>
> Recently I created an issue (CAMEL-1356) about exception handling and
> now I'm not really sure if it is really a bug or not. So I'm asking
> for your opinions.
>
> The problem is that when exception is caught it is set as a
> 'caught.exception' header on IN message. It means that if an exception
> is thrown on an exchange that already has OUT message it will be lost
> after the first step of a pipeline.
>
> We have few possible solutions here:
> 1) Keep it as it is - then we know where to look for this header in
> the first step of the pipeline - we can also use bean integration and
> @Header annotation to retrieve it)
> 2) Put the exception to header on OUT message if it is present - then
> it will be preserved in the pipeline. But then first step of the
> pipeline has to be clever - it has to look for it in OUT message.
> Moreover it is more general problem - if we allow OUT messages there,
> then you cannot use for example setHeader("foo") (you can, but it is
> useless, as out is propagated anyway)
> 3) Put it into exchange property - maybe the best solution as it is
> propagated, and we always know where to look for the exception. It
> will not be lost at some endpoint also.
>
> I believe this change should by put to 2.0 only as it might break
> someones exception handling completely, shouldn't it?
>
> This time I don't want to start flame about need for in/out messages
> once again, but... ;)
>
> Roman
>



-- 
Claus Ibsen
Apache Camel Committer

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