Get queues depth from java code
16,283
I doens't think there is a way to retrieve the queue depth using JMS. You can however use MQ Series specific Java API to retrieve this information. Here is the sample code. Pay attention to int openOptions = MQC.MQOO_INQUIRE;
Here is the reference guide
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();
}
Author by
user1080320
Updated on June 14, 2022Comments
-
user1080320 about 2 years
Can anyone help in doing the code in java of getting the depth of the queues. We are having 4 queues in IBM WebSphere MQ and inside them there are messages.
I want to write a jsp to read the queue names and their depth while running the report. How do I do that? Can anyone help in getting the full solution because I don't know what to do