Java program to connect WMQ with User Id instead of channel

耗尽温柔 提交于 2019-11-28 02:24:18

There are 2 ways for an MQ application to connect to a queue manager: bindings and client mode.

  • Bindings mode means that your MQ application is running on the SAME server as the queue manager. Hence, the MQI calls will not use network resources.

  • Client mode means that your MQ application can run on any server and it will use network resources when it issues MQI calls. For the MQCONN call, besides the queue manager name, you will also need the hostname/IP address, port # and channel name.

In either case, your MQ application should be supplying its user credentials (UserID & Password).

Finally, do NOT use the MQEnvironment class. It is far, far better to use a HashTable and pass it to the queue manager constructor class. i.e.

Hashtable<String, Object> mqht = new Hashtable<String, Object>();
mqht.put(CMQC.CHANNEL_PROPERTY, channelName);
mqht.put(CMQC.HOST_NAME_PROPERTY, hostName);
mqht.put(CMQC.PORT_PROPERTY, new Integer(portNumber));
mqht.put(CMQC.USER_ID_PROPERTY, userID);
mqht.put(CMQC.PASSWORD_PROPERTY, password);
try
{
   MQQueueManager qMgr = new MQQueueManager(qMgrName, mqht);
   System.out.println("Successfully connected to "+ qMgrName);
}
catch (com.ibm.mq.MQException mqex)
{
   System.out.println("MQException cc=" +mqex.completionCode + " : rc=" + mqex.reasonCode);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!