MQException:MQJE001:完成代码'2',尝试从队列中检索消息时,原因为'2033'

问题描述 投票:0回答:1

我尝试从队列中捕获消息。请注意,该消息具有xml内容。

但是,队列正确接收消息后,在块catch (MQException e)中引发了异常。

[MQException:MQJE001:完成码'2',原因'2033'

请查找以下使用的代码:

import com.ibm.mq.MQMessage
import com.ibm.mq.MQGetMessageOptions
import com.ibm.mq.MQQueueManager
import com.ibm.mq.constants.CMQC
import com.ibm.mq.headers.MQRFH2
import com.ibm.MQException

def mqProps = new Hashtable<String, Object>()
mqProps.put(MQConstants.CHANNEL_PROPERTY, 'mychannel')
mqProps.put(MQConstants.PORT_PROPERTY, myport)
mqProps.put(MQConstants.HOST_NAME_PROPERTY, 'myhost')

def qMgr = new MQQueueManager('myqueuemanager', mqProps)
def openOptions = MQConstants.MQOO_OUTPUT | MQConstants.MQOO_INPUT_AS_Q_DEF

def gmo = new MQGetMessageOptions()
gmo.options = CMQC.MQGMO_WAIT + CMQC.MQGMO_FAIL_IF_QUIESCING

def queue = qMgr.accessQueue('myqueue', openOptions)
MQMessage receiveMsg = null
boolean getMore = true
while(getMore) {
    receiveMsg = new MQMessage()

    try {
        // get the message on the queue
        queue.get(receiveMsg, gmo)
        def rfh2 = new MQRFH2(receiveMsg)
        def strucLen = rfh2.getStrucLength()
        def encoding = rfh2.getEncoding()
        def CCSID = rfh2.getCodedCharSetId()
        def format = rfh2.getFormat()
        def flags = rfh2.getFlags()
        def nameValueCCSID = rfh2.getNameValueCCSID()

        def b = new byte[receiveMsg.getDataLength()]
        receiveMsg.readFully(b)
        System.out.println("Data: " + new String(b))
        queue.close()
   } catch (MQException e) {
      if (e.completionCode == CMQC.MQCC_FAILED && e.reasonCode == CMQC.MQRC_NO_MSG_AVAILABLE) {
         // No message - loop again
      }
      else {
         log.info("MQException: " + e.getLocalizedMessage())
         log.info("CC=" + e.completionCode + " : RC=" + e.reasonCode)
         getMore = false
      }
   } catch (IOException e) {
      log.info("IOException:" + e.getLocalizedMessage())
   }

}

您能帮我修复它吗?谢谢。

jms ibm-mq mq
1个回答
0
投票

def openOptions = MQConstants.MQOO_OUTPUT |MQConstants.MQOO_INPUT_AS_Q_DEF

© www.soinside.com 2019 - 2024. All rights reserved.