Hi Minh,

I'm sorry, but I don't really understand how I can achieve what I want with a 
redelivery policy. I mean, sure, I guess the logging would work as I want, but 
I still want to be able to handle the Exchange when the error happens. How can 
I do that if I can't define a route that the Exchange should be sent to when an 
error occurs? Or can I do this with a redelivery policy, and if so, how?

/Jimi
________________________________________
From: Minh Tran <[email protected]>
Sent: Monday, April 18, 2016 2:22 AM
To: [email protected]
Subject: Re: How to log a Processor ERROR with stacktrace using 
DeadLetterChannel?

Hi

It’s easier to just define a redelivery policy profile and tell it what you 
want to log on exhausted. There are stacks of options you can set on it to 
customise it to exactly what you want to log.

See here for an example

http://camel.apache.org/redeliverypolicy.html 
<http://camel.apache.org/redeliverypolicy.html>

> On 18 Apr 2016, at 9:56 AM, [email protected] wrote:
>
> Hi,
>
>
>
> How can I log a Processor ERROR with stacktrace using DeadLetterChannel? Ie I 
> have a route with a Processor that throws an Exception of some kind, and the 
> route has a DeadLetterChannel configured, that sends the exchange to a 
> "error" route. And I would like this Exception to be logged on ERROR level, 
> with stacktrace.
>
>
>
> My setup, using Camel 2.17.0 and Camel Spring xml, looks something like this:
>
>
>
> <errorHandler id="deadLetterErrorHandler" type="DeadLetterChannel" 
> deadLetterUri="direct:error" />
>
>
>
> <camelContext>
> <route errorHandlerRef="deadLetterErrorHandler">
>  [...]
>  <process ref="myProcessor" /><!-- This throws an exception in method 
> process(Exchange) -->
>  [...]
> </route>
>
> <route>
>  <from uri="direct:error" />
>
>  <log logName="com.mycompany" loggingLevel="ERROR" message="Could not handle 
> file '${file:name}'" />
>
>  <to 
> uri="log:com.mycompany?level=ERROR&amp;showException=true&amp;showCaughtException=true&amp;showStackTrace=true"
>  />
>
>  [...]
> </route>
> <camelContext>
>
>
> The expected behaivor is that Camel logs the exception on ERROR logging 
> level, with stacktrace. The actual behaivor is that Camel logs the exception 
> like this:
>
>
>
> [...] DEBUG org.apache.camel.processor.DeadLetterChannel - Failed delivery 
> for (MessageId: 12345 on ExchangeId: 54321). On delivery attempt: 0 caught: 
> java.lang.IllegalArgumentException: Exception details...
>
>
>
> Ie it logs the exception on DEBUG log level, and without any stacktrace.
>
>
>
> What can I do to fix this?
>
>
>
> Regards
> /Jimi

Reply via email to