MQ队列连接管理器未断开连接

时间:2014-01-09 06:55:53

标签: java queue message-queue ibm-mq

我有一个从MQ读取的java方法,如下所示:

public String getMessage() throws SecurityException, IOException {
    MQMessage rcvMessage = new MQMessage();
    MQGetMessageOptions gmo = new MQGetMessageOptions();
    gmo.matchOptions = MQC.MQMO_MATCH_CORREL_ID;

    gmo.options = MQC.MQGMO_WAIT;
    int openOptions_1 = MQC.MQOO_INPUT_AS_Q_DEF;
    if (log.isInfoEnabled()) {
        log.info("Accessing queue: " + qName_out_get);
    }
    MQQueue queue1;
    String msgText = null;
    try {
        MQQueueManager qMgr = new MQQueueManager(qManager);
        queue1 = qMgr.accessQueue(qName_out_get, openOptions_1);

        queue1.get(rcvMessage, gmo);

        byte[] buffer = new byte[rcvMessage.getMessageLength()];
        rcvMessage.readFully(buffer);

        msgText = new String(buffer);
                        log.info("Final message is : " + msgText);



    } catch (MQException ex) {
        log.error("A WebSphere MQ Error occured : Completion Code "
                        + ex.completionCode
                        + " Reason Code "
                        + ex.reasonCode);
        for (Throwable t = ex.getCause(); t != null; t = t.getCause()) {
            log.error("... Caused by ");
        }
    } catch (IOException e) {
        log.error("An IOException occured whilst writing to the message buffer: "
                        + e);
    }
finally {
   queue1.close();
   qMgr.disconnect();
}
    return msgText;
}

我有代码来关闭队列并断开finally块中的队列管理器 但是,与queuemanager的连接没有被关闭。 有人能帮我一下吗? 提前致谢

1 个答案:

答案 0 :(得分:0)

这是一个小的初始化问题。 @Aniket Thakur:非常感谢你的时间