问一个关于 IBM WebSphere MQ的问题,消息错误代码为RC2019

miracle_yao 2015-05-12 03:54:18
我写了一个生产者程序,每隔5s往MQ发100条消息,又写了一个消费者程序,每隔10s从MQ中取消息,再写入文件,
生产者MQ主要代码:
MQQueue queue = null;
int openOptions = MQConstants.MQOO_OUTPUT
| MQConstants.MQOO_FAIL_IF_QUIESCING
| MQConstants.MQGMO_WAIT;
if (qMgr == null || !qMgr.isConnected()) {
qMgr = new MQQueueManager(qmName);
}

try {
queue = qMgr.accessQueue(qName, openOptions);

MQMessage putMessage = new MQMessage();
// putMessage.messageId = msgID.getBytes();
// putMessage.writeUTF(message);
putMessage.write(message.getBytes("UTF-8"));

MQPutMessageOptions pmo = new MQPutMessageOptions();

queue.put(putMessage, pmo);
queue.close();

} catch (Exception e) {
e.printStackTrace(System.out);
throw e;
} finally {
try {
if (queue != null) {
try {
queue.close();
} catch (MQException e) {
e.printStackTrace();
}
}
if (qMgr != null) {
qMgr.disconnect();
}
} catch (MQException e) {
throw e;
}
}

消费者MQ主要代码:
String[] messages = null;
int count = 0;
try {
qMgr = new MQQueueManager(qmName);
} catch (MQException e) {
throw e;
}

// @SuppressWarnings("deprecation")
// int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT
// | MQC.MQOO_INQUIRE;
// int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF |
// MQConstants.MQOO_OUTPUT;

int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF
| MQConstants.MQOO_INQUIRE ;
// | MQConstants.MQOO_FAIL_IF_QUIESCING;
MQQueue queue = null;
try {
queue = qMgr.accessQueue(qName, openOptions, null, null, null);

int depth = queue.getCurrentDepth();
messages = new String[depth];

// System.out.println("队列中的消息长度为:" + depth);
// 将队列中的消息读取出来
while (depth-- > 0) {
// System.out.println(depth);
MQMessage msg = new MQMessage();// 读取的队列消息
// msg.messageId = msgID.getBytes();

MQGetMessageOptions gmo = new MQGetMessageOptions();
queue.get(msg, gmo);

int len = msg.getDataLength();
byte[] buf = new byte[len];
msg.readFully(buf, 0, len);
String strmsgCont = new String(buf, "UTF-8");
messages[count++] = strmsgCont;
}
} catch (MQException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {

if (queue != null) {
try {
queue.close();
} catch (MQException e) {
e.printStackTrace();
}
}
if (qMgr != null) {
qMgr.disconnect();
}
}
return messages;
}
刚开始的几次,差不多20s内两边正常收发,之后就报了这个异常MQJE001: 完成代码为 '2',原因为 '2019'。
com.ibm.mq.MQException: MQJE001: 完成代码为 '2',原因为 '2019'。
看了IBM的官方文档解释,也是一头雾水,麻烦谁知道的告诉一下;


注:附IBM官方接释:
2019 (07E3) (RC2019): MQRC_HOBJ_ERROR
Explanation
The object handle Hobj is not valid, for one of the following reasons:
v The parameter pointer is not valid, or (for the MQOPEN call) points to
read-only storage. (It is not always possible to detect parameter pointers that are
not valid; if not detected, unpredictable results occur.)
v The value specified was not returned by a preceding MQOPEN call.
v The value specified has been made invalid by a preceding MQCLOSE call.
v The handle is a shared handle that has been made invalid by another thread
issuing the MQCLOSE call.
v The handle is a nonshared handle that is being used by a thread that did not
create the handle.
v The call is MQGET or MQPUT, but the object represented by the handle is not a
queue.
...全文
1314 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,633

社区成员

发帖
与我相关
我的任务
社区描述
WebSphere 是 IBM 的软件平台。它包含了编写、运行和监视全天候的工业强度的随需应变 Web 应用程序和跨平台、跨产品解决方案所需要的整个中间件基础设施,如服务器、服务和工具。
社区管理员
  • WebSphere社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧