miracle_yao 2015-05-12 07:46 采纳率: 0%
浏览 4646

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

我写了一个生产者程序,每隔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.

  • 写回答

1条回答 默认 最新

  • glglwj 2021-09-28 11:10
    关注

    请问解决了吗?也遇到了。。

    评论

报告相同问题?

悬赏问题

  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型