You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rhuiser <ro...@gmail.com> on 2013/12/29 09:19:40 UTC

Add custom header when message is rolled back to queue in transaction?

Hi all,

When a message ends-up on the designated DLQ when the max redelivery count
has reached, is it possible to add a custom header to this message?

What I would like is to have a header with the reason (exception) why the
messages could not be processed. This simplifies troubleshooting
tremendously.

Any ideas?

Robin




--
View this message in context: http://camel.465427.n5.nabble.com/Add-custom-header-when-message-is-rolled-back-to-queue-in-transaction-tp5745311.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Add custom header when message is rolled back to queue in transaction?

Posted by Henryk Konsek <he...@gmail.com>.
Hi guys,

> Does this mean I need to manage sending messages to the DLQ from within the
> route in the error handler?

No, the DLQ handler definition (deadLetterChannel("jms:queue:dead"))
is all you need. No extra wiring is required. Other routes don't need
to be aware of the DQL definition.

As far as I know DLQ doesn't participate in existing transaction.
Error handler just sends the copy of the message to the given
endpoint.

Cheers.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Add custom header when message is rolled back to queue in transaction?

Posted by rhuiser <ro...@gmail.com>.
Hi,

Thanks for your swift answer!

Does this mean I need to manage sending messages to the DLQ from within the
route in the error handler? 

If so, this means the route needs to be aware of the DLQ destination (in
stead of managing this centrally in the broker) and what happens to the
message if (for some reason) there is a failure when sending the message to
the DLQ (container fails where Camel is running)? Does this break the idea
of a transacted message? (Loosing the message?)

Robin





--
View this message in context: http://camel.465427.n5.nabble.com/Add-custom-header-when-message-is-rolled-back-to-queue-in-transaction-tp5745311p5745361.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Add custom header when message is rolled back to queue in transaction?

Posted by Richard Kettelerij <ri...@gmail.com>.
Otherwise (just an idea) you can try and use the onRedelivery mechanism of
Camel's DeadLetterErrorHandler. This allows you to plug-in your own
processor. Inside this processor you can use the
Exchange.REDELIVERY_COUNTER and Exchange.REDELIVERY_MAX_COUNTER properties
to figure out when it's time to set your own header.


On Sun, Dec 29, 2013 at 12:21 PM, Richard Kettelerij <
richardkettelerij@gmail.com> wrote:

> Hi,
>
> If I'm not mistaken you should already be able to get the exception from
> the exchange using the Exchange.EXCEPTION_CAUGHT property. Assuming you're
> using Camel's DeadLetterErrorHandler like this:
>
>
> errorHandler(deadLetterChannel("jms:queue:dead").maximumRedeliveries(3).redeliveryDelay(5000));
>
> You should be able to just call
> exchange.getProperty(Exchange.EXCEPTION_CAUGHT) on the exchanges in the
> "dead" queue and get the exception.
>
> Regards,
> Richard
>
>
> On Sun, Dec 29, 2013 at 9:19 AM, rhuiser <ro...@gmail.com> wrote:
>
>> Hi all,
>>
>> When a message ends-up on the designated DLQ when the max redelivery count
>> has reached, is it possible to add a custom header to this message?
>>
>> What I would like is to have a header with the reason (exception) why the
>> messages could not be processed. This simplifies troubleshooting
>> tremendously.
>>
>> Any ideas?
>>
>> Robin
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Add-custom-header-when-message-is-rolled-back-to-queue-in-transaction-tp5745311.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>

Re: Add custom header when message is rolled back to queue in transaction?

Posted by Richard Kettelerij <ri...@gmail.com>.
Hi,

If I'm not mistaken you should already be able to get the exception from
the exchange using the Exchange.EXCEPTION_CAUGHT property. Assuming you're
using Camel's DeadLetterErrorHandler like this:


errorHandler(deadLetterChannel("jms:queue:dead").maximumRedeliveries(3).redeliveryDelay(5000));

You should be able to just call
exchange.getProperty(Exchange.EXCEPTION_CAUGHT) on the exchanges in the
"dead" queue and get the exception.

Regards,
Richard


On Sun, Dec 29, 2013 at 9:19 AM, rhuiser <ro...@gmail.com> wrote:

> Hi all,
>
> When a message ends-up on the designated DLQ when the max redelivery count
> has reached, is it possible to add a custom header to this message?
>
> What I would like is to have a header with the reason (exception) why the
> messages could not be processed. This simplifies troubleshooting
> tremendously.
>
> Any ideas?
>
> Robin
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Add-custom-header-when-message-is-rolled-back-to-queue-in-transaction-tp5745311.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>