ok, I got it working now. Thanks.

What I did was simply adding an empty <redeliveryPolicy /> inside the 
<errorHandler> tag. It is a bit counter intuitive though that this changes the 
behaivor, since all I do is add a redeliveryPolicy  with no special 
configuration. Logically thinking, the result should be the same as the default 
behaivor, at least in my book. :)

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

Hi Jimi,

Ok now I understand your requirements more clearly :)

You can still achieve this by adding the redelivery policy with your error 
handler definition. Something like

<errorHandler id="deadLetterErrorHandler" type="DeadLetterChannel" 
deadLetterUri="direct:error” redeliveryPolicyRef=“myPolicy"=/>

What camel would do is run your custom route on error and then log the 
exhausted message after that.



> On 18 Apr 2016, at 11:08 AM, <[email protected]> 
> <[email protected]> wrote:
>
> Yes, exactly. I want Camel to log the error, so that we can analyze the 
> problem later (when looking at the log file), and at the same time handle the 
> Exchange in our "error" route, which basically means cleaning up some 
> temporary files, and moving some other files. So we don't "handle" the 
> Exchange in a way that makes Everything fine, we just do some extra stuff 
> that is needed when an error occurs. But the actuall logging of the ERROR 
> message, with stack trace, I expect Camel to do for me.
>
> /Jimi
> ________________________________________
> From: Minh Tran <[email protected]>
> Sent: Monday, April 18, 2016 2:59 AM
> To: [email protected]
> Subject: Re: How to log a Processor ERROR with stacktrace using 
> DeadLetterChannel?
>
> Hi Jimi
>
> What do you mean by "handle the Exchange when the error happens"? Do you mean 
> you want to do some custom processing when you receive that particular error 
> AND also log the stack trace?
>
>
>> On 18 Apr 2016, at 10:35 AM, <[email protected]> 
>> <[email protected]> wrote:
>>
>> 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