JMSExpiration vs TimeToLive

I am trying to set the expiration of a message in the Blueprint XML Camel route. The value that I want to set as expiration is stored inside the message body ( protobuf ).

Here is 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 in the screenshot below, I successfully set two of the three headers, but the setting for "JMSExpiration" (according to this topic ) has no effect.

ActiveMQWeb snippet

I know that, as an alternative, I could use a recipient list template for dynamically dialing uri - that is, extract expiration from the message data and add the parameter ?timeToLive=... However, this seems a little awkward to me.

Is there a way to set expiration via setHeader in XML?

Thanks,

J.

+6
source share
1 answer

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

Some JMS headers may be manually overridden as you try to use this option.

Please note that you can take some precautions, because if you listen to one JMS endpoint, incoming messages will be filled with JMS headers, and when you send a message in your "in", this message will be saved by JMSDeliveryMode , JMSExpiration and JMSPriority . This may or may not be what you want.

+3
source

All Articles