In the previous post, we took a brief look at some of the things we can learn from the queue manager using the DISPLAY command in runmqsc. It turns out that there is a lot of information available. So, what if we want to filter the results to see something more specific?
In WebSphere MQ version 6, the WHERE clause was introduced. This SQL-like expression allows an administrator to select a subset of results from the output of the DISPLAY command, based on the state of specific attributes. Users who have been using runmqsc for a long time, or who are new to the product, may not be aware of some of the things that are possible using this extended syntax.
The structure of the WHERE clause is WHERE(<attribute> <state> <value>) – for <state> we can substitute GT for Greater Than, LT for Less Than, EQ for Equals, and so on. You can find out more about the structure of the filter condition in the Infocenter.
In previous versions of WMQ, we could quickly find out how many messages were on a range of queue using DISPLAY QLOCAL(*) CURDEPTH. Unfortunately, that would show all of the queues. Of course, we could add a simple filter on part of the queue name to exclude the SYSTEM queues, using DIS QL(OURAPP.*). Now though, we can be a lot more specific. For example, to show all of the local queues whose depth is greater than 2, we could use WHERE(CURDEPTH GT 2):
dis ql(*) where (curdepth gt 2)
34 : dis ql(*) where (curdepth gt 2)
AMQ8409: Display Queue details.
QUEUE(SYSTEM.AUTH.DATA.QUEUE) TYPE(QLOCAL)
CURDEPTH(85)
AMQ8409: Display Queue details.
QUEUE(SYSTEM.CLUSTER.REPOSITORY.QUEUE)
TYPE(QLOCAL) CURDEPTH(45)
AMQ8409: Display Queue details.
QUEUE(XML) TYPE(QLOCAL)
CURDEPTH(3)
Now, what about the case were we want to know which of our channels are having problems. Which channels are currently in retry?
dis chs(*) where (status eq RETRYING)
32 : dis chs(*) where (status eq RETRYING)
AMQ8417: Display Channel Status details.
CHANNEL(TO.CLUSQM) CHLTYPE(CLUSSDR)
CONNAME(localhost(1414)) CURRENT
RQMNAME( ) STATUS(RETRYING)
SUBSTATE( ) XMITQ(SYSTEM.CLUSTER.TRANSMIT.QUEUE)
How many times has this happened to you: messages are mysteriously “disappearing” from a particular queue, but you don’t know which application is reading from it. I actually came across this exact issue recently – a colleague was telling me that messages were vanishing from one of her queues, and we couldn’t explain what was consuming them.
Here’s a really handy command. We’ll analyse it afterwards.
dis conn(*) where (appltype eq USER) pid connopts appltag userid channel
28 : dis conn(*) where (appltype eq USER) pid connopts appltag userid channel
AMQ8276: Display Connection details.
CONN(D4E4634620001002)
EXTCONN(414D51434C4142325F514D2020202020)
TYPE(CONN)
PID(3784)
APPLTAG(WebSphere MQ\bin\amqsput.exe)
APPLTYPE(USER) CHANNEL( )
CONNOPTS(MQCNO_SHARED_BINDING) USERID(mqtester)
Let’s just review what we asked for here.
We’ve asked the queue manager to tell us about all (*) of the CONNections it knows about, WHERE the APPLTYPE [application type] is USER – this means that the results will exclude the MQ queue manager system processes like the channel initiator, the channel agent, the listener, and so on.
We’ve then limited the information displayed to show only the PID [process ID], CONNOPTS [MQ connection options], APPLTAG [name of the binary], USERID [user that the process is running under] and CHANNEL [channel that the application is connecting over, if applicable]. There are a bunch of other attributes on the CONN object, but are not relevant to our scenario.
Play around with the WHERE clause on DISPLAY. By combining the new queue manager objects in WebSphere MQ version 6 and filtering the results using WHERE, it is possible to troubleshoot much more quickly.
This is currently the last planned post in this very short series on runmqsc. If you have any handy commands that you use often, feel free to include them in the comments - we might run another entry in the future that lists some of the more interesting combinations.

9 comments
Comments feed for this article
June 13, 2007 at 1:55 pm
John K
Dont forget to check out Paul Clarkes excellent MO72 SupportPac, which allows you to connect to remote queuemanagers and issue ‘runmqsc’ type commands on them, as well as edit the local channel table.
Played around with it (MO72) a little and created a small app that jumped around bewteen queuemanagers and listed the sender channels and used that input to draw a graph of how our MQ environment is connected
June 19, 2007 at 11:01 am
Ravi
Very useful article andy… Thanks a lot.
July 7, 2007 at 1:22 pm
FJ
To get back to your problem about who else was eating msgs from your queue:
dis conn(*) all where (objname eq MY.QUEUE.NAME) will give you information on who has the queue open.
This won’t help however when the app stealing your messages from you constantly opens and closes the queue (timing problem). I just thought we might have both investigative methods at hand.
I use it more often to kill stale client connections to allow me to use clear to empty a queue.
August 17, 2007 at 8:39 pm
Hatcher Jeter
Under wmq v6 can you do compound where clauses? ie dis ql(*) where (usage,eq,XMITQ) & (curdepth,ge,0)
August 21, 2007 at 1:09 pm
Dale Lane
@Hatcher – I don’t believe that you can do compound WHERE clauses in runmqsc.
August 26, 2007 at 12:53 pm
Anonymous
I like the idea of multiple where clause. Is this a current functionality in MQSC that i don’t know about or is this purely a pcf command option?
November 28, 2007 at 9:49 pm
Visitor
dis conn does not display connection start date and time. How to kill stale connections coming from same channel, conname but different timestamp ? The stale connections might be due to application crashed or kill -9 ?
January 31, 2008 at 4:59 pm
VARUN
That great to make conditional search on queue.
But what if I want to have multiple conditional search ?? AS WHEN I WANT TO DISPLAY ALL THE QLOCALS WITH USAGE TRANMISSION QUEUE AND CURRUNT DEPTH IS GREATER THEN 0 ??
as: DISPLAY QLOCAL(*) WHERE ( USAGE EQ XMITQ )
HOW TO PUT MULTIPLE CONDITIONS IN A WHERE CLAUSE ??
thanks.
VARUN.
January 31, 2008 at 5:13 pm
Dale Lane
I don’t believe that you can do compound WHERE clauses in runmqsc.
This was one my motivations in writing the PowerShell stuff – as it allows more powerful queries, such as the sort of multiple conditional searches that you are talking about.