IBM Support

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

Question & Answer


Question

Is there a way to delete a single message from an 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) One method to delete a single message is by using the following SupportPac in an MQ Explorer in Windows or in Linux x86 that can remotely connect to the queue manager in AIX.
.
The following SupportPac MS0P has the feature "Message Manager" that can be used to delete a message, to copy/move it to another queue, or copy it into a file
Download the zip file, and from the pdf file see: Message Manager Plug-in, Page 28
https://www.ibm.com/support/pages/node/712469
MS0P: WebSphere MQ Explorer – Extended Management Plug-ins and Tools
.
WebSphere MQ Explorer plug-in for Events and Statistics reports
Plug-ins
• The original plug-in written for this SupportPac provides a mechanism to format Event messages; it can aggregate the Statistics and Accounting reports generated by MQ from Version 6 onwards.
• There is a plug-in to display current activity on queues and channels as a simple graph.
• The package also implements the "Trace Route" function, reporting on the route that messages take through a network.
• A plug-in to allow information shown in many of the Explorer’s tables, such as the list of queues defined on a queue manager, to be saved to a CSV (comma-separated value) file where it can be processed by programs such as spreadsheets.
*** Another plug-in extends the Message Browser, to allow messages to be deleted, moved to another queue, or written to a file. ***
• A Wizard makes it simple to define connections between two queue managers.
• The topic objects defined on a queue manager can be displayed in a tree structure, to make it easier to see the relationships between them.
• Queue Manager configurations can be extracted using the dmpmqcfg command. This is accessible via the Remote Admin plug-in for queue managers at V7.1 or later, or via the main list of queue managers in the Explorer tree, if the dmpmqcfg command is part of that Explorer installation.

c) There is another 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:
Author: Angel Rivera;
+++ 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:
15 April 2024

UID

ibm16416577