我對ibm mq很陌生,發現與mb相關的文檔或書籍非常少,我找到的唯一一本是2004年編寫的「WebSphere MQ Using Java」但現實世界已經發生了很大變化。 我安裝並根據this使用java連接到ibm mq 7.5的問題
我還創建隊列管理myqm1
,隊列LQ.TEST
,信道JAVA.CHANNEL
上成功RedHat Linux上的64位驗證MQ服務器7.5和確實通過上服務器命令行一些測試,以確保它們工作得很好。然而,當我安裝了Windows XP的一個MQ客戶端及以下java代碼寫的,它總是拋出一個exception:com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2035'
我的代碼:
進口com.ibm.mq. *; import com.ibm.mq.constants.MQConstants;
/** *簡單的示例程序*/public類MQSample {
// code identifier static final String sccsid = "@(#) MQMBID sn=p000-L120604 su=_H-IvIK4nEeGko6IWl3MDhA pn=MQJavaSamples/wmqjava/MQSample.java"; // define the name of the QueueManager private static final String qManager = "myqm1"; // and define the name of the Queue private static final String qName = "LQ.TEST"; /** * Main entry point * * @param args - command line arguments (ignored) */ public static void main(String args[]) { try { MQEnvironment.hostname = "58.2.221.196"; MQEnvironment.channel = "JAVA.CHANNEL"; MQEnvironment.port = 1414; MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES); MQEnvironment.userID = "mqm"; MQEnvironment.password = "mqm"; MQEnvironment.CCSID = 1208; // Create a connection to the QueueManager System.out.println("Connecting to queue manager: " + qManager); MQQueueManager qMgr = new MQQueueManager(qManager); // Set up the options on the queue we wish to open int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT; // Now specify the queue that we wish to open and the open options System.out.println("Accessing queue: " + qName); MQQueue queue = qMgr.accessQueue(qName, openOptions); // Define a simple WebSphere MQ Message ... MQMessage msg = new MQMessage(); // ... and write some text in UTF8 format msg.writeUTF("Hello, World!"); // Specify the default put message options MQPutMessageOptions pmo = new MQPutMessageOptions(); // Put the message to the queue System.out.println("Sending a message..."); queue.put(msg, pmo); // Now get the message back again. First define a WebSphere MQ // message // to receive the data MQMessage rcvMessage = new MQMessage(); // Specify default get message options MQGetMessageOptions gmo = new MQGetMessageOptions(); // Get the message off the queue. System.out.println("...and getting the message back again"); queue.get(rcvMessage, gmo); // And display the message text... String msgText = rcvMessage.readUTF(); System.out.println("The message is: " + msgText); // Close the queue System.out.println("Closing the queue"); queue.close(); // Disconnect from the QueueManager System.out.println("Disconnecting from the Queue Manager"); qMgr.disconnect(); System.out.println("Done!"); } catch (MQException ex) { ex.printStackTrace(); System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode + " Reason Code " + ex.reasonCode); } catch (java.io.IOException ex) { System.out.println("An IOException occured whilst writing to the message buffer: " + ex); } return; } }
可有人扔一盞燈,我這句話?我完全失望了。
可能相關:http://stackoverflow.com/questions/5101840/error-2035-mqrc-not-authorized-while-connecting-to-mq – beny23
看起來像你的用戶名和密碼可能是錯誤的,因爲2035是'NOT已授權' – beny23
您是否甚至向Google詢問'com.ibm.mq.MQException:MQJE001:完成代碼'2',原因'2035'? – home