I have a requirement to delete the messages from reply queue. I need to check if the message put time is 15 mins prior to current time, I need to delete those messages. For ex. if there are 5 messages out of which 3 have arrived after 11 AM and 2 messages before 11 AM. If current time is 11.15AM, then I have to dlete the 2 messages which have arrived before 11AM. How can I do this?
Typically, the application which MQPUT(1)s the reply message would specify an expiry interval in the MQMD of the reply message. Once this expiry interval has elapsed, MQ will flag the message as unavailable and MQ's housekeeping will take care of deleting it.
Otherwise, your application processing the reply queue needs to MQGET every message (specify MQMI-NONE and MQCI_NONE) and check the MQMD.PutTime against the current time. Doing this, you then probably need some mechanism to correlate the replies that you will not simply delete with the corresponding request messages.
I'd rethink the application design to use MQ facilities.