使用JMS的Java客户端连接到IBM MQ Channel的TCP / IP抛出错误

时间:2019-07-11 08:16:11

标签: java ibm-mq

我们在Windows服务器计算机上运行了IBM MQ Server 7.5。到目前为止,我们在Windows上有一个IBM MQ JMS客户端(以groovy编写),用于读取TCP通道上的消息。

我现在的问题是我们必须将Client移到Debian机器上。 我已经下载了Debian的IBM MQ Client 7。

我正在编写一个示例代码以连接到服务器以读取消息。 我正在使用IBM网站上的JmsPutGet.java示例。

环境如下:

  1. Java 8
  2. com.ibm.mq.allclient-9.0.4.0.jar
  3. javax.jms-api-2.0.1

我得到的错误是

The value specified for the property is not supported.
Modify the value to be within the range of accepted values.
FAILURE

我也尝试使用连接模式Client,它给出了如下不同的错误:

com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: Failed to connect to queue manager 'VIMSRRI10' with connection mode 'Client' and host name '172.18.21.5(1415)'.
Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.
Inner exception(s):
com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2539' ('MQRC_CHANNEL_CONFIG_ERROR').
com.ibm.mq.jmqi.JmqiException: CC=2;RC=2539;AMQ9204: Connection to host '172.18.21.5(1415)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2539;AMQ9547: Type of remote channel not suitable for action requested. [3=IRRICI10.VIMSRRI10]],3=172.18.21.5(1415),5=RemoteConnection.analyseErrorSegment]
com.ibm.mq.jmqi.JmqiException: CC=2;RC=2539;AMQ9547: Type of remote channel not suitable for action requested. [3=IRRICI10.VIMSRRI10]
FAILURE

示例Java代码为:

JmsFactoryFactory ff =  JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();

// Set the properties
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, HOST);
cf.setIntProperty(WMQConstants.WMQ_PORT, PORT);
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, CHANNEL);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_DIRECT_TCPIP);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, QMGR);
cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "JmsPutGet (JMS)");
//cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
//cf.setStringProperty(WMQConstants.USERID, APP_USER);
//cf.setStringProperty(WMQConstants.PASSWORD, APP_PASSWORD);

// Create JMS objects
context = cf.createContext();
System.out.println("After Context\n");
destination = context.createQueue("queue:///" + QUEUE_NAME);
System.out.println("After Queue\n");
long uniqueNumber = System.currentTimeMillis() % 1000;
TextMessage message = context.createTextMessage("Your lucky number today is " + uniqueNumber);

producer = context.createProducer();
producer.send(destination, message);
System.out.println("Sent message:\n" + message);

consumer = context.createConsumer(destination); // autoclosable
String receivedMessage = consumer.receiveBody(String.class, 15000); // in ms or 15 seconds

System.out.println("\nReceived message:\n" + receivedMessage);

1 个答案:

答案 0 :(得分:3)

您连接到的频道必须为SVRCONN

错误reason '2539' ('MQRC_CHANNEL_CONFIG_ERROR')表示您要连接的频道不是SVRCONN

在错误的下一行中将其清楚说明,该错误还提供了您尝试连接到IRRICI10.VIMSRRI10的频道的名称:

AMQ9547: Type of remote channel not suitable for action requested. [3=IRRICI10.VIMSRRI10]

通道本身的名称对于两个队列管理器之间使用的SDRRCVR通道来说是通用的格式,而不是要连接的MQ客户端应用程序。