0

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

TheBohne
  • 79
  • 1
  • 10

1 Answers1

2

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.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • Thanks for your answer :) But at the moment my messages are deleted if they have a TTL. Is that normal? My goal is that when the TTL is reached the message is put into the DLQ and given a new TTL of 0, or in other words when a message is in the DLQ it is never deleted. Maybe this is the default behavior and I messed something up in the configuration. Can you tell me the default behavior? – TheBohne Jun 08 '22 at 16:25
  • Are you sending to topics or queues? – Tim Bish Jun 08 '22 at 20:04
  • To both. Process looks like this: Some Service X -> Send to topic -> Send to 3 Queues -> Service for each queue -> Send to Queue – TheBohne Jun 09 '22 at 07:08
  • 1
    Try setting processExpired to true as otherwise you've disabled expired message processing for the DLQ – Tim Bish Jun 10 '22 at 15:38