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

问一个关于 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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥50 滴滴出行模拟系统,模拟叫车、出行过程等过程
  • ¥15 信号发生器如何将频率调大,步尽值改成10
  • ¥15 keil 5 编程智能家具,风扇台灯开关,人体感应等
  • ¥100 找一名渗透方面的专家
  • ¥20 使用Matlab gui设计一个插补小程序
  • ¥15 evo评估时曲线出现问题
  • ¥15 eNSP拓扑图配置实验
  • ¥20 有没有兄弟会替换fmod studio的.bank文件内的音效?
  • ¥20 如何解决访问网址被屏蔽的情况
  • ¥20 powerbuilder datawindow控件导出Excel数据,可不可以不自动覆盖原数据,而是在后面新插入入数据。