首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > 其他服务器 >

java取MQ深度的有关问题

2012-03-09 
java取MQ深度的问题public void receive() {MapString, MQ mqMap getMQ()MQQueueManager manager n

java取MQ深度的问题
public void receive() {
Map<String, MQ> mqMap = getMQ();
MQQueueManager manager = null;
Map<String, MQQueue> map = new HashMap<String, MQQueue>();
for (Iterator it = mqMap.entrySet().iterator(); it.hasNext();) {
Map.Entry e = (Map.Entry) it.next();
if (manager == null) {
manager = getManager((MQ) e.getValue());
}
map.put((String) e.getKey(), getQueue(manager, ((MQ) e.getValue()).getQueueName()));
}
MQGetMessageOptions mqGetMessageOptions = new MQGetMessageOptions();
mqGetMessageOptions.options = mqGetMessageOptions.options + MQC.MQGMO_SYNCPOINT + MQC.MQGMO_WAIT
+ MQC.MQGMO_FAIL_IF_QUIESCING;
mqGetMessageOptions.waitInterval = MQC.MQWI_UNLIMITED;

log.normal("MsgCenter listen all queues message");
while (manager != null) {
for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
Map.Entry e = (Map.Entry) it.next();
try {
if (((MQQueue) e.getValue()).getCurrentDepth() > 0) {
MQMessage mqMessage = new MQMessage();
((MQQueue) e.getValue()).get(mqMessage, mqGetMessageOptions);
int index = mqMessage.getMessageLength();
byte[] buffer = new byte[index];
mqMessage.readFully(buffer, 0, index);
String message = new String(buffer,"GBK");
//log.normal("MsgCenter receive from " + (String) e.getKey() + " message:\n" + message);
log.normal("MsgCenter insert message into db");
messageInsertDB(MessageXmlUtil.xmlConvertMessage(message));
manager.commit();
}
} catch (MQException e1) {
e1.printStackTrace();
log.error("Exception Type:" + e1);
log.error("Exception Localtion:" + e1.getStackTrace()[0]);


} catch (IOException e2) {
e2.printStackTrace();

}
}
}

这是我的程序,当MQ运行正常的时候,程序正常。MQ关闭了以后报错
MQJE001:完成码 2,原因码 2019
com.ibm.mq.MQException: MQJE001:完成码 2,原因码 2019
at com.ibm.mq.MQManagedObject.inquire(MQManagedObject.java:257)
at com.ibm.mq.MQManagedObject.getInt(MQManagedObject.java:428)
at com.ibm.mq.MQQueue.getCurrentDepth(MQQueue.java:1612)
at com.inspur.pb.rmc.msg.MsgReceiver.receive(MsgReceiver.java:90)
at com.inspur.pb.rmc.main.RMC.main(RMC.java:35)
[2010-11-15 15:16:55]-[Error]-[com.inspur.pb.rmc.msg.MsgReceiver]
[Exception Type:com.ibm.mq.MQException: MQJE001:完成码 2,原因码 2019]

MQ重新启动了以后程序继续报上述错误。

我想的是如果网络断了又重新连接以后,程序可以继续运行,不报错,该怎么改啊?

[解决办法]

热点排行