Automatically clear messages from queue in IBM MQ

I was wondering if there is a way for you to configure a queue to automatically clear messages? We are striving to partially implement a component of our architecture and want to be able to send to the queue, but have the queue automatically remove the messages that are being sent so that we don't have to run scripts, etc to perform the clean-up.

So far the only thing I have been able to find is to run CLEAR QLOCAL or set the messages to expire from the publishing application.


Solution 1:

For you use case there are a few options in IBM MQ:

  1. Create a QALIAS that points to a TOPIC object which has a topic string with no subscribers, messages put to the QA will just disappear.
  2. Have the sending application set message expiry.
  3. Use the IBM MQ CAPEXPRY feature to administratively force message expiry at the queue level.
  4. Run a script to issue CLEAR QLOCAL against the queue. There can not be open handles on the queue for this to work.
  5. Programmatically issue the equivalent PCF command to CLEAR QLOCAL against the queue. There cannot be open handles on the queue for this to work.
  6. Run the IBM MQ dmpmqmsg utility against the queue to read and discard the messages.