解決在IBM MQ獨立的應用程序解決MQRC 2195個錯誤
我找到了答案,從IBM Technote IZ66146
希望它可以幫助別人有同樣的問題。
我寫了一個簡單的方法來從MQ隊列中讀取消息。
在循環中,我嘗試讀取消息(使用waitInterval)。從隊列中成功讀取消息後,返回2195返回代碼。我該如何解決這個問題?
這裏是我的代碼沒有異常處理或任何其他事情的簡化版本。
public static void main(String args[]) {
MQException.logExclude(MQException.MQRC_NO_MSG_AVAILABLE);
MQException.logExclude(MQException.MQRC_UNEXPECTED_ERROR);
MQException.log = null;
while (true) {
incomeDeployMsg = readFromQueue(waitReadInterval);
System.out.println(dateFormater.format(new Date()) + " Income msg");
}
}
public String readFromQueue(int waitInterval) throws MQException{
MQMessage message = new MQMessage();
try {
if (m_inQueue == null || !m_inQueue.isOpen())
m_inQueue = m_mqQmgr.accessQueue(m_inQueueName, CMQC.MQOO_INQUIRE + CMQC.MQOO_FAIL_IF_QUIESCING + CMQC.MQOO_INPUT_SHARED);
message.messageId = CMQC.MQMI_NONE;
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = CMQC.MQGMO_WAIT;
gmo.waitInterval = waitInterval;
m_inQueue.get(message, gmo);
return message.readStringOfCharLength(message.getMessageLength());
} catch (MQException mqe) {
throw mqe;
} finally {
message.clearMessage();
}
}
在結果的第一行是不是從我的代碼!我認爲這是IBM的標準輸出打印出來的類。我如何解決錯誤?
結果:
MQJE001:完成代碼 '2',原因 '2195'。
2013年5月15日11點44分27秒的收入味精
有一個在代碼中沒有異常引發。這是當它從隊列中成功讀取消息「get」方法執行後自動寫入。 (NOT EXCEPTION) – happyNewLife