When are expired WebSphere MQ messages removed from a queue?
ValerieLampkin 27000182R2 Comments (6) Visits (45941)
I’ve had a few people who want to know how to delete expired messages or they have seen messages being removed and are wondering where they’ve gone. I’ll try to address how message expiry is handled by WebSphere MQ.
Messages are not removed by issuing runmqsc commands. When a message’s expiry time has elapsed, it becomes eligible to be discarded by the queue manager. The message is discarded when a browse or nonbrowse MQGET call occurs that would have returned the message had it not already expired. For example, a nonbrowse MQGET call with the MatchOptions field in MQGMO set to MQMO_NONE reading from a FIFO ordered queue discards all the expired messages up to the first unexpired message.
However, if no such call occurs, the expired message is not discarded and expired messages could accumulate.
To remedy this situation on the z/OS platform, you can specify a time period for messages to be removed with the EXPRYINT (expiry interval) queue manager attribute. Each time the expiry interval is reached, the queue manager scans queues to discard expired messages.
Another option is to issue the REFRESH QMGR TYPE(EXPIRY) command, specifying the queue or queues that you want scanned.
See Expired messages on z/OS in the WebSphere MQ information center for more details.
If your queue manager is located on a UNIX distributed platform, MQ V6 has incorporated an expirer task that works in a similar fashion for distributed platforms.
For further information about the expirer task for distributed platforms, see this technote: Expired messages are discarded or disappearing from a queue.
In older versions of MQ, an expired message would have remained on the queue until a browse or a destructive MQGET which would retrieve the message was performed and at that time the expiry is checked and message discarded. However, if you have MQ V6 or MQ V7 then the internal expirer task should remove the expired messages. By default, internal scanning to discard the expired messages would happen every 300 seconds, but that parameter can be altered using the ExpiryInterval parameter under the TuningParameters stanza in the qm.ini file.
For additional details on the EXPIRY attribute, see Expiry (MQLONG) in the WebSphere MQ information center.