从Java代码获取队列深度 [英] Get queues depth from java code

查看:288
本文介绍了从Java代码获取队列深度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助在Java中获取队列深度的代码.在IBM WebSphere MQ中有4个队列,并且在其中有消息.

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.

我想编写一个jsp来在运行报告时读取队列名称及其深度.我怎么做? 任何人都可以帮助获得完整的解决方案,因为我不知道该怎么办

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

推荐答案

我不认为有一种使用JMS检索队列深度的方法.但是,您可以使用MQ系列特定的Java API来检索此信息.这是示例代码.注意int openOptions = MQC.MQOO_INQUIRE;

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;

这是参考指南

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();
}

这篇关于从Java代码获取队列深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆