Hi Rashmitha,
I think you were almost there with your research already.
You are quite right that messages can have an TTL (time-to-live) set using the MQMD.Expiry field.
When a message has a TTL set, the queue manager will automatically delete (aka expire) messages whose TTL has passed.
You can set the TTL of a message, either in the application directly, or though a queue attribute called CAPEXPRY (note - no letter 'i' in the name)
The queue attribute means that you can do this without modifying the application code.
To set a 30 minute TTL with the queue attribute you would use CAPEXPRY(18000) - i.e. this value is configured in 10ths of a second.
To set a 1 day TTL with the queue attribute you would use CAPEXPRY(864000)
In case it is not obvious, you cannot have both of these set on the same queue.
Also note that only new messages that are put into the queue after the change in CAPEXPRY make use of it.
Here is some extra reading material about CAPEXPRY
Cheers,
Morag
------------------------------
Morag Hughson
MQ Technical Education Specialist
MQGem Software Limited
Website:
https://www.mqgem.com------------------------------
Original Message:
Sent: Mon October 13, 2025 06:33 PM
From: Rashmitha Thukuntla
Subject: Message Expiry vs Queue-Level Retention - Need help
I have an IBM MQ queue configured with MAXDEPTH(50000)
.
The consuming application processes messages but only needs data that's less than 30 minutes old - anything older becomes irrelevant for processing.
I'm exploring if MQ can automatically handle message cleanup in such cases.
I'm aware that IBM MQ has no native queue-level TTL (time-to-live) setting for messages, and that expiry is typically handled at the message level via the MQMD.Expiry
field.
Questions:
1️⃣ Can IBM MQ automatically delete or expire messages that are older than 30 minutes?
2️⃣ Is there any way to set a 1-day retention period on the queue itself so that messages get automatically deleted after 24 hours, without modifying the producer or application code?
Appreciate your time. Looking forward to hearing some solution.
------------------------------
Rashmitha Thukuntla
------------------------------