You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by lw <li...@gmail.com> on 2016/01/29 23:56:40 UTC

onException block in camel 2.16.1

Hello, I'm testing functionality of my existing files from camel 2.14 on
updated camel 2.16.1 version. It appears that camel DefaultErrorHandler
responds to the error after the error is handled by onException block. In
console I see my error handled message + new timestamp with the full trace
of the same error coming from DefaultErrorHandler. I'd like to turn off
default full trace. I tested with removing trace attribute from context and
adding onException block at context level, but so far had no luck. Id like
to see only my message in the log. Here is the route sample with onException
block:      

    <route id="mrPost">
        <from uri="activemq:mrPost?concurrentConsumers=8" />
        <onException>
            <exception>java.lang.Exception</exception>
            <redeliveryPolicy maximumRedeliveries="2"
redeliveryDelay="1000"/>
            <handled>
                    <constant>true</constant>
            </handled>

            <to uri="activemq:mr-post-fail" />

            <log loggingLevel="ERROR" message="Error posting to MR
body:${out.body} exception message: ${exception.message}
body:${exception.responseBody}" />  
        </onException> 

        <setHeader headerName="CamelHttpMethod">
           <constant>PUT</constant>
        </setHeader>
        <recipientList>
            <simple>{{mr.source}}/${headers.id}</simple>
        </recipientList>

    </route>


My handled error:
2016-01-26 15:07:09,571 [Camel (mrPostContext) thread #56 -
JmsConsumer[mrPost]] ERROR mrPost - Error posting to Merlin  .....

And the DefaultErrorHandler error following my handled error: 
2016-01-26 15:07:09,571 [Camel (mrPostContext) thread #56 -
JmsConsumer[mrPost]] ERROR org.apache.camel.processor.DefaultErrorHandler -
Failed delivery for (MessageId:
ID-qn7nwscms01-com-34265-1453747060905-10-75492 on ExchangeId:
ID-qn7nwscms01-com-34265-1453747060905-10-75493). Exhausted after delivery
attempt: 3 caught:
org.apache.camel.http.common.HttpOperationFailedException: HTTP operation
failed invoking.... 



--
View this message in context: http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: onException block in camel 2.16.1

Posted by Andreas Siepert <an...@gmail.com>.
HI again,
when configuring the errorhandler like this:
errorHandler(defaultErrorHandler()
.logExhausted(false)
);

the errorHandler won't log.
Another parameter can be set with .logHandled(false) - false is set per
default - and i expected that there would be no log when the exception had
been handled. Any ideas about it?

Best regards
Andreas

2016-01-30 19:01 GMT+01:00 Andreas Siepert <an...@gmail.com>:

> Hi, my post some days ago relates to the changed behavior too. Until 2.16.
> one could be sure that no defaulterrorhandler kicks in when an exception
> was marked as handled.
> Could please someone clarify if it is a bug or a configuration issue.
>
> Thanks
> Andreas
> Am 30.01.2016 15:19 schrieb "TygerC" <su...@iki.fi>:
>
>> I was going to post the same question since the behaviour is a bit
>> puzzling.
>>
>> Why is it working now this way? I couldn't find any documentation
>> regarding
>> the matter.
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777044.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>

Re: onException block in camel 2.16.1

Posted by Andreas Siepert <an...@gmail.com>.
Hi, my post some days ago relates to the changed behavior too. Until 2.16.
one could be sure that no defaulterrorhandler kicks in when an exception
was marked as handled.
Could please someone clarify if it is a bug or a configuration issue.

Thanks
Andreas
Am 30.01.2016 15:19 schrieb "TygerC" <su...@iki.fi>:

> I was going to post the same question since the behaviour is a bit
> puzzling.
>
> Why is it working now this way? I couldn't find any documentation regarding
> the matter.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777044.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: onException block in camel 2.16.1

Posted by TygerC <su...@iki.fi>.
I was going to post the same question since the behaviour is a bit puzzling. 

Why is it working now this way? I couldn't find any documentation regarding
the matter.



--
View this message in context: http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777044.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: onException block in camel 2.16.1

Posted by Claus Ibsen <cl...@gmail.com>.
You can turn on | off | levels and whatnot on the error handler. There
you can turn off showing stacktraces etc.

On Fri, Jan 29, 2016 at 11:56 PM, lw <li...@gmail.com> wrote:
> Hello, I'm testing functionality of my existing files from camel 2.14 on
> updated camel 2.16.1 version. It appears that camel DefaultErrorHandler
> responds to the error after the error is handled by onException block. In
> console I see my error handled message + new timestamp with the full trace
> of the same error coming from DefaultErrorHandler. I'd like to turn off
> default full trace. I tested with removing trace attribute from context and
> adding onException block at context level, but so far had no luck. Id like
> to see only my message in the log. Here is the route sample with onException
> block:
>
>     <route id="mrPost">
>         <from uri="activemq:mrPost?concurrentConsumers=8" />
>         <onException>
>             <exception>java.lang.Exception</exception>
>             <redeliveryPolicy maximumRedeliveries="2"
> redeliveryDelay="1000"/>
>             <handled>
>                     <constant>true</constant>
>             </handled>
>
>             <to uri="activemq:mr-post-fail" />
>
>             <log loggingLevel="ERROR" message="Error posting to MR
> body:${out.body} exception message: ${exception.message}
> body:${exception.responseBody}" />
>         </onException>
>
>         <setHeader headerName="CamelHttpMethod">
>            <constant>PUT</constant>
>         </setHeader>
>         <recipientList>
>             <simple>{{mr.source}}/${headers.id}</simple>
>         </recipientList>
>
>     </route>
>
>
> My handled error:
> 2016-01-26 15:07:09,571 [Camel (mrPostContext) thread #56 -
> JmsConsumer[mrPost]] ERROR mrPost - Error posting to Merlin  .....
>
> And the DefaultErrorHandler error following my handled error:
> 2016-01-26 15:07:09,571 [Camel (mrPostContext) thread #56 -
> JmsConsumer[mrPost]] ERROR org.apache.camel.processor.DefaultErrorHandler -
> Failed delivery for (MessageId:
> ID-qn7nwscms01-com-34265-1453747060905-10-75492 on ExchangeId:
> ID-qn7nwscms01-com-34265-1453747060905-10-75493). Exhausted after delivery
> attempt: 3 caught:
> org.apache.camel.http.common.HttpOperationFailedException: HTTP operation
> failed invoking....
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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

Re: onException block in camel 2.16.1

Posted by lw <li...@gmail.com>.
Awesome! Your solution works much cleaner! Thank you!




--
View this message in context: http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777165.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: onException block in camel 2.16.1

Posted by Claus Ibsen <cl...@gmail.com>.
I visited a Camel user and they had the issue too, where handled
exceptions was still being logged.

It was only Splunk who benefited because they sent ERRORs from the
logs to splunk, and it cost $$$ :(



On Fri, Feb 5, 2016 at 5:16 PM, Andreas Siepert
<an...@gmail.com> wrote:
> Great!
> Am 05.02.2016 16:59 schrieb "Claus Ibsen" <cl...@gmail.com>:
>
>> Hi
>>
>> Yeah thanks for reporting and discussing this. We have found the bug
>> and its fixed in the next release.
>>
>> On Tue, Feb 2, 2016 at 10:21 AM, Andreas Siepert
>> <an...@gmail.com> wrote:
>> > Opened an issue https://issues.apache.org/jira/browse/CAMEL-9558
>> >
>> > Regards
>> > Andi
>> >
>> > 2016-02-02 7:51 GMT+01:00 TygerC <su...@iki.fi>:
>> >
>> >> Setting the logging level off works fine:
>> >>
>> >> <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler"
>> >> logName="LoggingErrorHandler" level="OFF"/>
>> >>
>> >> And also doTry/doCatch work: the exception won't go the the error
>> handler
>> >> from the catch  block.
>> >>
>> >> But: it this a bug or a feature? I really don't like a behaviour that I
>> >> don't understand.
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777131.html
>> >> Sent from the Camel - Users mailing list archive at Nabble.com.
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> http://davsclaus.com @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>



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

Re: onException block in camel 2.16.1

Posted by Andreas Siepert <an...@gmail.com>.
Great!
Am 05.02.2016 16:59 schrieb "Claus Ibsen" <cl...@gmail.com>:

> Hi
>
> Yeah thanks for reporting and discussing this. We have found the bug
> and its fixed in the next release.
>
> On Tue, Feb 2, 2016 at 10:21 AM, Andreas Siepert
> <an...@gmail.com> wrote:
> > Opened an issue https://issues.apache.org/jira/browse/CAMEL-9558
> >
> > Regards
> > Andi
> >
> > 2016-02-02 7:51 GMT+01:00 TygerC <su...@iki.fi>:
> >
> >> Setting the logging level off works fine:
> >>
> >> <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler"
> >> logName="LoggingErrorHandler" level="OFF"/>
> >>
> >> And also doTry/doCatch work: the exception won't go the the error
> handler
> >> from the catch  block.
> >>
> >> But: it this a bug or a feature? I really don't like a behaviour that I
> >> don't understand.
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777131.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: onException block in camel 2.16.1

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

Yeah thanks for reporting and discussing this. We have found the bug
and its fixed in the next release.

On Tue, Feb 2, 2016 at 10:21 AM, Andreas Siepert
<an...@gmail.com> wrote:
> Opened an issue https://issues.apache.org/jira/browse/CAMEL-9558
>
> Regards
> Andi
>
> 2016-02-02 7:51 GMT+01:00 TygerC <su...@iki.fi>:
>
>> Setting the logging level off works fine:
>>
>> <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler"
>> logName="LoggingErrorHandler" level="OFF"/>
>>
>> And also doTry/doCatch work: the exception won't go the the error handler
>> from the catch  block.
>>
>> But: it this a bug or a feature? I really don't like a behaviour that I
>> don't understand.
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777131.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>



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

Re: onException block in camel 2.16.1

Posted by Andreas Siepert <an...@gmail.com>.
Opened an issue https://issues.apache.org/jira/browse/CAMEL-9558

Regards
Andi

2016-02-02 7:51 GMT+01:00 TygerC <su...@iki.fi>:

> Setting the logging level off works fine:
>
> <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler"
> logName="LoggingErrorHandler" level="OFF"/>
>
> And also doTry/doCatch work: the exception won't go the the error handler
> from the catch  block.
>
> But: it this a bug or a feature? I really don't like a behaviour that I
> don't understand.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777131.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: onException block in camel 2.16.1

Posted by TygerC <su...@iki.fi>.
Setting the logging level off works fine:

<errorHandler id="loggingErrorHandler" type="LoggingErrorHandler"
logName="LoggingErrorHandler" level="OFF"/>

And also doTry/doCatch work: the exception won't go the the error handler
from the catch  block.

But: it this a bug or a feature? I really don't like a behaviour that I
don't understand.



--
View this message in context: http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777131.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: onException block in camel 2.16.1

Posted by lw <li...@gmail.com>.
I got the defaultErrorHandler to collapse with these 2 adjustments:
 - set  messageHistory="false"  on CONTEXT
-  set  logStackTrace="false" for onException block, like this:
<redeliveryPolicy maximumRedeliveries="2" redeliveryDelay="1000"
logStackTrace="false" />
The timestamp with default error handler still shows up, but much easier on
the eye.
I tried 
<errorHandler id="defaultErrorHandler" type="DefaultErrorHandler">
    <redeliveryPolicy  logStackTrace="false"/>
</errorHandler>

but it makes no impact. I'll post if I'll get more time and find a better
solution.



--
View this message in context: http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-tp5777019p5777110.html
Sent from the Camel - Users mailing list archive at Nabble.com.