Java program to connect WMQ with User Id instead of channel

前端 未结 1 2103
你的背包
你的背包 2020-12-07 06:06

I have the requirement like connecting MQ with userid instead of channel.

I have tried with setting user id and password without chanel to MQEnvironment class but go

相关标签:
1条回答
  • 2020-12-07 06:44

    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);
    }
    
    0 讨论(0)
提交回复
热议问题