IBM Support

Is there a way to delete a single message from an IBM MQ queue (arbitrary position in the queue)?

Question & Answer


Question

Is there a way to delete a single message from an IBM MQ queue (arbitrary position in the queue)?

Answer

a) You can use the MQ utility "dmpmqmsg" for a message in a specific position. Attribute: -r position
 For the specific scenario of deleting the 1st message in a queue, see the following article:
https://www.ibm.com/support/pages/node/7148300
Using IBM MQ dmpmqmsg to delete only the first message from a queue
An example to delete the 1st message from queue Q1 and create an output file with the contents of that message (in the format used by dmpmqmsg) is:
  dmpmqmsg -m QM93WIN -I Q1 -r 1 -f deleted-message-1.txt
An example to MOVE the 1st message from Q1 to Q2 is:
  dmpmqmsg -m QM93WIN -I Q1 -o Q2 -r 1
 
b) You can use the MQ utility "dmpmqmsg" based on a MessageID. Attribute: -gxm MessageID
For example, via MQ Explorer or amqsbcg you see that the MessageId for the desired message that you want to delete is:
 
414D5120514D393357494E2020202020F4C0F96501AB0240
Then the following command will do a Destructive Get (effectively a Delete) and store the message in an output file specified by -f:
dmpmqmsg -m QM -IQ1 -gxm414D5120514D393357494E2020202020F4C0F96501AB0240 -f out.txt
c) Starting with the MQ Web Console 9.4, it is possible to delete 1 message from a queue.
+ begin excerpt
[MQ 9.4.0 Jun 2024]
To delete an individual message from a queue:
   Locate the message that you want to delete.
   Click the delete icon next to the message shows the delete icon.
   Confirm that you want to clear the message by clicking Delete.
+ end excerpt
d) There is an old SupportPac that is a command line interface that if you know the messageid of the message that you want to delete from the queue (for example, obtained from amqsbcg, the MQ sample to browse a queue), then you can delete that message.
Example:
To do a destructive get, use -IQ1 (where Q1 is the name of the queue).
q -IQ1 -mQMgr -gxm414D5120514D5F373031202020202020D49F695020001D05
 
+ tags:
Authors: Angel Rivera; Christian Montes;
+++ end +++

[{"Line of Business":{"code":"LOB67","label":"IT Automation \u0026 App Modernization"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSYHRD","label":"IBM MQ"},"ARM Category":[{"code":"a8m0z00000008ObAAI","label":"Components and Features-\u003EAdministration"}],"ARM Case Number":"TS004883981","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Document Information

Modified date:
08 July 2024

UID

ibm16416577