如果我的replyToQueueManagerName和replyToQueueName与requestQueueuManagerName和requestQueueName不在同一个MQEnvironment中,该怎么办?
例:
//MQEnvironment for requestMessage
MQEnvironment.hostname = requestMessageHost;
MQEnvironment.channel = requestMessageChannel;
MQEnvironment.port = requestMessagePort
MQQueueManager qMgr = new MQQueueManager(requestQueueuManagerName);
MQQueue inputQueue = qMgr.accessQueue(requestQueueName,MQC.MQOO_OUTPUT);
MQMessage requestMessage = new MQMessage();
MQPutMessageOptions pmo = new MQPutMessageOptions();
requestMessage.writeString(sampleXmlRequest);
requestMessage.replyToQueueManagerName = replyToQueueManagerName;
requestMessage.replyToQueueName = replyToQueueName;
在VB.NET中,可以连接到驻留在不同环境中的QueueManager和Queue。
最佳答案
我假设您正在问MQEnvironment
已用于连接到队列管理器时如何连接到另一个队列管理器。
您可以通过哈希表提供连接信息来创建与队列管理器的连接。这段代码在C#中。
Hashtable mqProps = new Hashtable();
mqProps.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
mqProps.Add(MQC.HOST_NAME_PROPERTY, "<yourhost>");
mqProps.Add(MQC.PORT_PROPERTY, port);
mqProps.Add(MQC.CHANNEL_PROPERTY, "<svrconn channel name>");
MQQueueManager qmConn = new MQQueueManager("replyQM", mqProps);
这是Java代码:
Hashtable<String, Object> properties;
properties = new Hashtable<String, Object>();
properties.put("hostname", "replyqmhost");
properties.put("port", new Integer(1414));
properties.put("channel", "REPLYQM.SVRCONN");
properties.put(MQConstants.USE_MQCSP_AUTHENTICATION_PROPERTY,true);
properties.put(MQConstants.USER_ID_PROPERTY, "<user id>");
properties.put(MQConstants.PASSWORD_PROPERTY, "<password>");
/**
* Connect to a queue manager
*/
MQQueueManager queueManager = new MQQueueManager("replyQM", properties);