What are MQ EXPIRY messages and how do I implement them?
Answer by Gregory(Greg)Bowman (8958) | Aug 30, 2017 at 02:17 PM
Expiry messages contain a period of time, for which they are valid, set by an application that performs an MQPUT. The expiry time is a field in the message descriptor(MQMD) of a message which gets decremented as the message spends time on a queue. When a message is retrieved(MQGET) by an application, prior to expiration, the expiry time represents the amount of time left from the original time specified. When a message's expiry time has elapsed, it becomes eligible for discard by the queue manager. The message is discarded when a browse or nonbrowse MQGET occurs on the message.
A report message may be requested, when a message expires and is discarded before it is retrieved(MQGET) from a queue, if the MQPUT application specifies one of the MQRO_EXPIRATION_* report options. If none of these options is specified, no report is generated.
EXPIRY Report Options
If you want a report generated, you must specify one of the following options:
1)MQRO_EXPIRATION
Report message.
2)MQRO_EXPIRATION_WITH_DATA
Report message with first 100 bytes of original message included.
3)MQRO_EXPIRATION_WITH_FULL_DATA
Report message with all of original message included.
EXPIRY message and report parameters
In the message descriptor, MQMD, you must specify the following fields:
1)Expiry
The period of time, expressed in tenths of a second, a message is eligible to be successfully retrieved(MQGET) before it is discarded.
2)Report
The type of report being requested ie, MQRO_EXPIRATION. This field is optional.
3)ReplyToQ
The name of the queue to which the report should be sent.
4)ReplyToQmgr
The name of the queue manager to which the report should be sent.
Portion of Sample C Code:
/* Expiry of 5 minutes */
md.Expiry = 3000;
/* Report option */
md.Report = MQRO_EXPIRATION_WITH_DATA;
/* Reply to Queue name */
memcpy(md.ReplyToQ, "EXPIRY.REPORTS ", MQ_Q_NAME_LENGTH);
/* Reply to QMGR name */
memcpy(md.ReplyToQMgr, "IBMTEST ", MQ_Q_MGR_NAME_LENGTH);
Note: This information was originally in technote # 1636236