You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Laurentiu Trica <la...@moredevs.ro> on 2017/10/17 13:35:42 UTC

Camel doTry

Hello,

I need your help with error handling in doTry/doCatch.
I have to put the doTry in my route and do some stuff if there is an
exception, but I also need the exception to be passed along and end up in
the logs - I use Camel in Servicemix.

Why the bellow example* doesn't work as expected? I mean the exception is
caught, but even if the handled is set to false, the exception doesn't end
up in my logs.

<route>
    <from uri="direct:start"/>
    <doTry>
        <process ref="processorFail"/>
        <to uri="mock:result"/>
        <doCatch>
            <exception>java.io.IOException</exception>
            <!-- mark this as NOT handled, eg the caller will also get the
exception -->
            *<handled>*
*                <constant>false</constant>*
*            </handled>*
            <to uri="mock:io"/>
        </doCatch>
    </doTry>
</route>

* copied from:
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2.1/html/Apache_Camel_Development_Guide/BasicPrinciples-ExceptionHandling.html#BasicPrinciples-ExceptionHandling-doTry-Rethrow

Can you please help?

Thanks,
Laurentiu

Re: Camel doTry

Posted by Laurentiu Trica <la...@moredevs.ro>.
Hi,

I discovered that, in fact, the exception is not handled (just as I want it
to be), but the log doesn't record either the stack trace, nor the Message
History.
Any idea why this would happen? Is it the normal behavior? Can I change it?

Thanks!
Laurentiu

On Tue, Oct 17, 2017 at 4:35 PM, Laurentiu Trica <
laurentiu.trica@moredevs.ro> wrote:

> Hello,
>
> I need your help with error handling in doTry/doCatch.
> I have to put the doTry in my route and do some stuff if there is an
> exception, but I also need the exception to be passed along and end up in
> the logs - I use Camel in Servicemix.
>
> Why the bellow example* doesn't work as expected? I mean the exception is
> caught, but even if the handled is set to false, the exception doesn't end
> up in my logs.
>
> <route>
>     <from uri="direct:start"/>
>     <doTry>
>         <process ref="processorFail"/>
>         <to uri="mock:result"/>
>         <doCatch>
>             <exception>java.io.IOException</exception>
>             <!-- mark this as NOT handled, eg the caller will also get the
> exception -->
>             *<handled>*
> *                <constant>false</constant>*
> *            </handled>*
>             <to uri="mock:io"/>
>         </doCatch>
>     </doTry>
> </route>
>
> * copied from: https://access.redhat.com/documentation/en-US/Red_
> Hat_JBoss_Fuse/6.2.1/html/Apache_Camel_Development_Guide/BasicPrinciples-
> ExceptionHandling.html#BasicPrinciples-ExceptionHandling-doTry-Rethrow
>
> Can you please help?
>
> Thanks,
> Laurentiu
>

Re: Camel doTry

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

Using handled=false on doTry is deprecated and you should not do that.
In the Java DSL you will notice its deprecated.

And yes its the expected behaviour as its deprecated and you are
explicit doing a try .. catch style.

Use onException instead as it can log the message history / stacktrace etc.


On Tue, Oct 17, 2017 at 3:35 PM, Laurentiu Trica
<la...@moredevs.ro> wrote:
> Hello,
>
> I need your help with error handling in doTry/doCatch.
> I have to put the doTry in my route and do some stuff if there is an
> exception, but I also need the exception to be passed along and end up in
> the logs - I use Camel in Servicemix.
>
> Why the bellow example* doesn't work as expected? I mean the exception is
> caught, but even if the handled is set to false, the exception doesn't end
> up in my logs.
>
> <route>
>     <from uri="direct:start"/>
>     <doTry>
>         <process ref="processorFail"/>
>         <to uri="mock:result"/>
>         <doCatch>
>             <exception>java.io.IOException</exception>
>             <!-- mark this as NOT handled, eg the caller will also get the
> exception -->
>             *<handled>*
> *                <constant>false</constant>*
> *            </handled>*
>             <to uri="mock:io"/>
>         </doCatch>
>     </doTry>
> </route>
>
> * copied from:
> https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2.1/html/Apache_Camel_Development_Guide/BasicPrinciples-ExceptionHandling.html#BasicPrinciples-ExceptionHandling-doTry-Rethrow
>
> Can you please help?
>
> Thanks,
> Laurentiu



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2