我很新的IBM MQ,我发现的文件或相关MB的书有这么几个,我发现只有一个“的WebSphere MQ使用Java”写于2004年,但在现实世界已经改变了很多。 我安装在RedHat Linux 64位验证MQ服务器7.5成功地根据本
我还创建队列管理器myqm1
,排队LQ.TEST
,通道JAVA.CHANNEL
并没有通过服务器上的命令行一些测试,以确保它们正常工作。 然而,当我安装了Windows XP的一个MQ客户端及以下java代码写的,它总是抛出一个exception:com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2035'
我的代码:
进口com.ibm.mq. *; 进口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; } }
任何人都可以抛出一盏灯,我这句话? 我完全下来。