Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMSExpiration vs TimeToLive

I'm trying to set message expiration within a Blueprint XML Camel route. The value I want to set as the expiration is held within the message body (a protobuf).

Here's my code:-

<setHeader headerName="AMQ_SCHEDULED_DELAY">
    <method bean="NotificationScheduler" method="postponeSending" />
</setHeader>
<setHeader headerName="JMSExpiration">
    <method bean="NotificationScheduler" method="getExpiry" />
</setHeader>
<setHeader headerName="ExpirationTest">
    <method bean="NotificationScheduler" method="getExpiry" />
</setHeader>
<to uri="activemq:notifications.splitter" />

As you can see from the screen shot below, I'm successfully setting two of the three headers but the setting for "JMSExpiration" (as per this thread) has had no effect.

ActiveMQWeb snippet

I know I could alternatively use the Recipient List pattern to dynamically set the uri - i.e. pull the expiry out of the message data and append the ?timeToLive=... option. However, this seems a little clunky to me.

Is there a way to set expiration via setHeader within the XML?

Thanks,

J.

like image 417
Jeremy Gooch Avatar asked Apr 06 '13 11:04

Jeremy Gooch


1 Answers

Change your uri to: activemq:notifications.splitter?preserveMessageQos=true and you should be fine.

Some JMS headers can be "manually" overriden like you are trying to by using this option.

Please note that you might want to take some precausion, since if you are listening on one JMS endpoint, the arriving messages will have JMS headers populated, and when you send the message out in your "to", the message will keep JMSDeliveryMode, JMSExpiration and JMSPriority. This might or might not be what you want.

like image 135
Petter Nordlander Avatar answered Oct 19 '22 23:10

Petter Nordlander