Check the Queue Depth/Total Number of Messages in a MQ Queue

I want to know if there is any way to check for the total number of messages on any given MQ Queue, thru wM ofcourse.

I am trying to build some tools to enable/disable listeners based on certain business rules, i need to make sure that a set of queues are cleared off before i can enable the 2nd set.

Any help/input is highly appreciated.

Best regards…

In the past, I used the MQ Java API to create a simple Java service that returned the queue depth.

Mark

Mark,

thanks for the quick response.

I am not very good with java services, I’d appreciate if you can guide me with that.

Soujanya

If you are using the current (6.5) version of the Websphere MQ Adapter, you can configure “Inquire Queue Manager / Queue Services” to return the current depth of a specific queue. See p 149 of the MQ Adapter User’s Guide for details.

Mark

Mark,

Unfortunately, i am on 6.0…

I checked for that feature on 6.0 couldn’t find any. I think the JAVA is the only option for me.

Thank you for the help.

Soujanya

You might want to press the right people in your organization to start working on updating the installation. Development support for IS 6.0.1 ended last year and maintenance support ends next month. If you need help from wM on anything that comes up, they’re going to turn you down unless you update.

Pretty sure that IBM has a truck load of samples / examples for the Websphere MQ Java API. You would need to find one that queried the queue depth property for a queue and then tailor it to run as an IS java service.

The java service would require that the Websphere MQ jars be in the IS server’s classpath (either from the package’s code\jars folder or from the IS \lib\jars folder).

Once this was in the class path, you would import the packages or classes needed by the example and write your java service.

If these tasks are more advanced than you prefer to tackle, then your only option is to upgrade to the 6.5 version of the Websphere MQ Adapter.

Mark

Mark,

I think i will be ok with the JAVA, i wanted to go for it as a last option, i wish we can upgrade but thats another issue.

Reamon - 6.0 is the wM MQ Adapter maybe i shuld have been more specific in my notes. our IS is 6.1 the support for 6.1 will end in Dec. we already raised a request to upgrade to 7.0 and there is some research going on about that.

Thanks to you both,

Soujanya

Ah, I see. I misread the thread.

Here is the sample code, just in case someone googles this post.

 int depth = 0;
MQQueueManager qMgr; // define a queue manager object
String mqHost = "";
String mqPort = "";
String mqChannel = "";
String mqQMgr = "";
String mqQueue = "";
try {
    // Set up MQSeries environment
   MQEnvironment.hostname = mqHost;
   MQEnvironment.port = Integer.valueOf(mqPort).intValue();
   MQEnvironment.channel = mqChannel;
   MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,
   MQC.TRANSPORT_MQSERIES);
   qMgr = new MQQueueManager(mqQMgr);
   int openOptions = MQC.MQOO_INQUIRE;
   MQQueue destQueue = qMgr.accessQueue(mqQueue, openOptions);
   depth = destQueue.getCurrentDepth();
   destQueue.close();
   qMgr.disconnect();
} catch (Exception err) {
   err.printStackTrace();
}