我寫了一些Java代碼來啓動和停止MQ通道。我在MQ上創建了一個服務器連接通道來測試此代碼。但是在執行Java代碼時,通道的啓動和停止都會產生錯誤。MQ通道重啓代碼給出錯誤
停止通道給出瞭如下錯誤:
about to stop channel
MQJE001: Completion Code 2, Reason 2202
啓動通道提供了以下錯誤:
com.ibm.mq.MQException: MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
代碼:
package com.asm.MQListenerChannelRestart;
import com.ibm.mq.pcf.*;
import com.ibm.mq.*;
import com.ibm.mq.pcf.CMQCFC;
public class MQListenerChannelRestart implements CMQCFC {
public void startChannel(PCFAgent pcfAgent){
PCFParameter [] parameters = new PCFParameter [] {
new MQCFST (MQCACH_CHANNEL_NAME, "TESTChanne"),
new MQCFST(MQCACH_USER_ID,"user"),
new MQCFST(MQCACH_PASSWORD,"password")
};
try {
System.out.println("about to start channel");
MQMessage [] pcfResponses = pcfAgent.send (MQCMD_START_CHANNEL,
parameters);
MQCFH cfh = new MQCFH(pcfResponses[0]);
System.out.println("Parameter count="+cfh.parameterCount);
System.out.println("Reason = "+cfh.reason);
System.out.println(cfh.toString());
pcfResponses = pcfAgent.send(MQCMD_INQUIRE_CHANNEL_STATUS, parameters);
cfh = new MQCFH(pcfResponses[0]);
System.out.println("Channel status is ==="+cfh.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
public void stopChannel(PCFAgent pcfAgent){
PCFParameter [] parameters = new PCFParameter [] {
new MQCFST (MQCACH_CHANNEL_NAME, "TESTChanne"),
new MQCFIN (MQIACF_QUIESCE, MQQO_NO)
};
try {
System.out.println("about to stop channel");
MQMessage [] pcfResponses = pcfAgent.send (MQCMD_STOP_CHANNEL,
parameters);
MQCFH cfh = new MQCFH(pcfResponses[0]);
System.out.println("Parameter count="+cfh.parameterCount);
System.out.println("Reason = "+cfh.reason);
System.out.println(cfh.toString());
pcfResponses = pcfAgent.send(MQCMD_INQUIRE_CHANNEL_STATUS, parameters);
cfh = new MQCFH(pcfResponses[0]);
System.out.println("Channel status is ==="+cfh.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
PCFAgent pcfAgent = null;
MQListenerChannelRestart mqListenerChannelRestart = new MQListenerChannelRestart();
mqListenerChannelRestart.stopChannel(pcfAgent);
mqListenerChannelRestart.startChannel(pcfAgent);
}
}
有人可以幫我解決這個問題嗎?
使用一致和邏輯縮進代碼塊。代碼的縮進旨在幫助人們理解程序流程! – 2013-05-14 11:49:58
請給出完整的代碼片段,特別是pcfAgent對象創建的代碼。 – Shashi 2013-05-14 12:14:50
我現在提供了整個代碼...感謝 – 2013-05-15 04:45:50