无法连接到远程MQ

时间:2016-08-30 03:56:49

标签: ibm-mq

我正在尝试连接到远程IBM MQ服务器。但我收到错误无法加载库mqjbnd.dll。我不确定为什么绑定模式会被使用。下面粘贴了一段代码。在阅读各种回复后,包括堆栈溢出,发现客户端模式应该用于我的场景。但我无法配置客户端模式。任何有关这方面的帮助将不胜感激

// 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);

1 个答案:

答案 0 :(得分:1)

When you are using client mode , series of properties will need to be set as you are connecting using TCP/IP . This for example will include , host , port and details that are needed for the program to connect to a QM over the network. An indicative example is here.

Hashtable<String, Object> mqKeyValueProps = new Hashtable<String, Object>();
mqKeyValueProps.put(CMQC.HOST_NAME_PROPERTY, hostName);
mqKeyValueProps.put(CMQC.PORT_PROPERTY, new Integer(portNumber));
mqKeyValueProps.put(CMQC.CHANNEL_PROPERTY, channelName);
mqKeyValueProps.put(CMQC.USER_ID_PROPERTY, userID);
mqKeyValueProps.put(CMQC.PASSWORD_PROPERTY, password);
try
{

    MQQueueManager qMgr = new MQQueueManager(qManager,mqKeyValueProps);

    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);
}
catch (com.ibm.mq.MQException mqex)
{
   System.out.println("MQException cc=" +mqex.completionCode + " : rc=" + mqex.reasonCode);
}