Hi Camel community,

I am facing a problem using the Camel's deadLetterChannel.

I have several Routes that process messages and delegate to a Route-scoped
errorHandler when something bad happen (HTTP endpoint timeout for instance).

What I try to achieve is to implement a generic Route as deadLetterChannel
to handle all kind of Route failure and act accordingly (actually, persist
object on the filesystem and send an email).

The problem is that filename and mail subject are different, depending on
the Route the failure was triggered from. I need to implement some logic to
retrieve the failure context (i.e. from which Route it was triggered) and
set some headers accordingly.

Is there a possibility to retrieve failed Route (instance / ID or URI) via
the Exchange object (Processor) ? If it's not the case, can we set headers
in the Route specific errorHandler that will be used in the generic
deadLetterChannel (worse as Route depends on caller) ? Do you see a better
way ?

My Java code currently looks like that :

MyRoute route definition :

from(MyRoute.URI).routeId(MyRoute.ID)
   
.errorHandler(deadLetterChannel(DeadLetterRoute.URI).useOriginalMessage()
       
.maximumRedeliveries(maximumRedeliveries).redeliveryDelay(redeliveryDelay)
        .log(MyRoute.FAILURE).logHandled(true)
        .retriesExhaustedLogLevel(LoggingLevel.ERROR).logStackTrace(true)
       
.retryAttemptedLogLevel(LoggingLevel.WARN).logRetryStackTrace(false))
     // ... Route's stuff ...

DeadLetterRoute route definition :

from(DeadLetterRoute.URI).routeId(DeadLetterRoute.ID)
    .process(new DeadLetterProcessor()) // Retrieves failed route and set
headers accordingly
    .setHeader("from", simple("${properties:mail.from}"))
    .setHeader("to", simple("${properties:mail.to}"))
    .to("file:{{error.directory}}")
    .to("smtp:{{mail.server.url}}");


Thanks in advance for your help,
Nicolas



--
View this message in context: 
http://camel.465427.n5.nabble.com/Retrieve-failed-Route-from-deadLetterChannel-tp5725420.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to