简体   繁体   中英

How to set expiry for specific ActiveMQ queue


the documentation of ActiveMQ is giving me a hard time so you are my last hope :D

What i want:
An expiration date on messages in the outgoing queue. Messages in the incoming, DLQ and RTS Queue should stay for ever.

So expiration is always 0 except when a message is put in the outgoing queue. Then ActiveMQ has to set a new expiration day. Alternatively this could also be set by the Application

Or alternatively (maybe easier):
An expiration date on messages in the outgoing and incoming queue. Messages in the DLQ and RTS Queue should stay for ever.

So expiration is always 12345 (or so) except when a message is transfer to RTS or DLQ. Then ActiveMQ has to set the new expiration day to 0

What i tried:

  1. Setting an expiry date for the outgoing messages explicitly in the application message.setJMSExpiration(XYZ); however, the expiration date was then always set to 0 . Probably because of the spring jms lib
  2. Configure the deadLetterStrategy so all messages in the DLQ get a expiration of 0 . But seems to have no effect. probably misconfigured

 <deadLetterStrategy> <individualDeadLetterStrategy processNonPersistent="true" queuePrefix="DLQ." useQueueForQueueMessages="true" processExpired="false" expiration="0"/> </deadLetterStrategy>

Maybe you can help me :)
Thank you in advance

Spring-jms:5.3.20
ActiveMQ:5.15.15

The JMS Message setJMSExpiration is explicitly documented as bit being meant for use by the user so that explains why calling it isn't working for you.

This method is for use by JMS providers only to set this field when a message is sent. This message cannot be used by clients to configure the expiration time of the message. This method is public to allow a JMS provider to set this field when sending a message whose implementation is not its own.

To define a time to live for the message you either need to use the JMS Producer method setTimeToLive or the send method that allows you to provide the TTL value on a per message basis.

Alternatively you can configure the ActiveMQ Timestamp Plugin to apply a TTL value to each incoming message.

If you want expired messages to go into the DLQ then I'd suggest not configuring the broker to not do that as you've done above by setting processExpired="false" as that is specifically telling the broker not to DLQ expired messages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM