永发信息网

mq java 怎么判断队列为空

答案:1  悬赏:50  手机版
解决时间 2021-03-20 06:41
mq java 怎么判断队列为空
最佳答案
MQException
该类包含WebSphere MQ 完成代码和错误代码常量的定义。以MQCC_开始的常量是WebSphere MQ 完成代码,而以MQRC_开始的常量则是WebSphere MQ 原因代码。只要出现WebSphere MQ
错误,就会给出MQException。
MQGetMessageOptions
该类包含控制MQQueue.get()方法行为的选项。
MQManagedObject
该类是MQQueueManager、MQQueue 和MQProcess 类的超类。它提供查询并设置这些资源属性的能力。

------解决方案--------------------
去取一次,得到 2033 错误就是没有消息符合你的条件。

使用 PCF 查询队列资料:


public QueueInfo queryQueueInfo() throws Exception {
if (!checkStatus2(this.queueManager)) {
throw new IllegalStateException("Not Connected to queue manager.");
}

PCFMessageAgent agent = null;

try {
agent = new PCFMessageAgent(this.queueManager);

// Inquiry Queue Name & Current Depth.
int[] attrs = {
CMQC.MQCA_Q_NAME, CMQC.MQIA_CURRENT_Q_DEPTH,
CMQC.MQIA_OPEN_INPUT_COUNT, CMQC.MQIA_OPEN_OUTPUT_COUNT,
CMQC.MQIA_Q_TYPE, CMQC.MQIA_DEFINITION_TYPE, CMQC.MQIA_INHIBIT_GET,
CMQC.MQIA_INHIBIT_PUT };

PCFParameter[] parameters = {
new MQCFST(CMQC.MQCA_Q_NAME , getInputQueue().getText().trim()),
new MQCFIL(CMQCFC.MQIACF_Q_ATTRS , attrs) };

// logger.log("Querying current depth of current queue.");
MQMessage[] responses = agent.send(CMQCFC.MQCMD_INQUIRE_Q, parameters);

QueueInfo info = new QueueInfo();

for (int i = 0; i < responses.length; i++) {
MQCFH cfh = new MQCFH(responses[i]);

// Check the PCF header (MQCFH) in the response message

if (cfh.reason == 0) {
String name = "";
Integer depth = new Integer(0);

for (int j = 0; j < cfh.parameterCount; j++) { // Extract what we want from the returned attributes

PCFParameter p = PCFParameter.nextParameter(responses[i]);

switch (p.getParameter()) {
case CMQC.MQCA_Q_NAME:
name = (String) p.getValue();
info.name = name;
break;
case CMQC.MQIA_CURRENT_Q_DEPTH:
depth = (Integer) p.getValue();
info.depth = depth.intValue();
break;
case CMQC.MQIA_OPEN_INPUT_COUNT:
Integer inputCount = (Integer) p.getValue();
info.inputCount = inputCount.intValue();
break;
case CMQC.MQIA_OPEN_OUTPUT_COUNT:
Integer outputCount = (Integer) p.getValue();
info.outputCount = outputCount.intValue();
break;
case CMQC.MQIA_Q_TYPE:
info.type = ((Integer) p.getValue()).intValue();
break;
case CMQC.MQIA_DEFINITION_TYPE:
info.definitionType = ((Integer) p.getValue()).intValue();
break;
case CMQC.MQIA_INHIBIT_PUT:
info.putNotAllowed = ((Integer) p.getValue()).intValue() == 1;
break; case CMQC.MQIA_INHIBIT_GET:
info.getNotAllowed = ((Integer) p.getValue()).intValue() == 1;
default:
}
}

// System.out.println("Queue " + name + " curdepth " + depth);

return info;

} else {
System.out.println("PCF error:\n" + cfh);

// Walk through the returned parameters describing the error

for (int j = 0; j < cfh.parameterCount; j++) {
System.out.println(PCFParameter.nextParameter(responses[0]));
}

throw new Exception("PCF Error [reason :" + cfh.reason + "]");
}
}

return null;

} catch (Exception e) {
throw e;
} finally {
if (agent != null) {
try {
agent.disconnect();
} catch (Exception e) {
logger.log(e);
}
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
江苏公务员考试A、B、C科目是什么?
怎么删除百度地图上传店面的图片
07式海军军服几个问题?
黄家驹去世的时候,日本当时赔偿了多少人民币
朋友,就是我们自己选择的家人。 求解释!
狗狗的命们在哪个位置?
电脑显卡怎么提高
培艺美术培训中心在哪里啊,我有事要去这个地
2007年国家有关部门联合征集“10000个科学难
屏幕上的小圆是什么
七代雅阁远光灯型号多少?
酒店学徒和厨师学校哪个好?
不小心按了网络猫的复位键,结果电脑连不到网
css中ax和ay代表什么
马自达3昂克赛拉两厢好还是三厢好
推荐资讯
大竹一重百度云全集下载
我喜欢一个女孩我把她q删了,她又把我加回来
烦躁的近义词是什么
什么裤子配耐克air max图片库
22岁能考舞蹈学校吗
文献综述的国外现状和国内现状的格式可以一样
曼谷从素万那普机场到廊曼机场怎么走?
天达汽车同步器齿轮制造公司在什么地方啊,我
韶关市仁化县某中小型水电站
语句printf("s=%0.2f\n",s);
兰花可以水培吗吗?需要注意些什么?
苯酚是酸吗
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?