On 14 May 2013, at 18:10, Peter Hilton <pedro+ca...@lunatech.com> wrote:
> I have a route that takes a file, parses it and then sends JSON to a web 
> service. If the Camel processor that parses the file throws a parse 
> exception, the configured error handler moves the file to the dead letter 
> endpoint. This much works.
> 
>       errorHandler(deadLetterChannel(failureEndpoint).disableRedelivery())
> 
> However, I *also* want to log an error with the parse exception that the 
> parser throws. How should I do this?

I now have something that works.

After reading enough of the Scala DSL unit tests, I added the following to my 
route builder:

        handle[Exception] {
          log(LoggingLevel.ERROR, "${id} ${exception}")
          to(failureEndpoint)
        }.handled

It doesn't appear to be necessary to call maximumRedeliveries(0) on handle, 
since I don't get retries when I do this.

This is not ideal because I would prefer this to be a single statement, e.g. 
using a custom component, to be able to customise the log output, and to 
include the stack trace. I may get to those things, but I've run out of time 
for now.

Peter

Reply via email to