IBM MQ - Purge messages in a queue using the amqsget command
by
Jeremy Canfield |
Updated: May 04 2021
| IBM MQ articles
The amqsget command can be used to GET the messages in the queue. If your goal is to remove all of the messages in a queue, the clear queue command is probably a better option.
Before using the amqsget command to get the messages in a queue, you may want to use the display queue command to display the number of messages in the queue.
echo "display queue (QUEUE01) CURDEPTH" | runmqsc MANAGER01
In this example, the current depth of queue01 is 10.
QUEUE(queue01) TYPE(QLOCAL)
CURDEPTH(10)
The amqsget command can be used to GET the messages in the queue. Be aware that this will remove the message from the queue as this is a GET operation. If you are unsure of the <mq install> directory, use the dspmqinst command.
<mq install>/samp/bin/amqsget QUEUE01 MANAGER01
Sample AMQSGET0 start
message <Hello World>
Sample AMQSGET0 end
If there are no messages in the queue, the following will be displayed.
<mq install>/samp/bin/amqsget QUEUE01 MANAGER01
Sample AMQSGET0 start
no more messages
Sample AMQSGET0 end
Did you find this article helpful?
If so, consider buying me a coffee over at
Comments
January 06 2022 by Albert
This was helpful - thanks!