我正在尝试向IBM MQ(版本:9.0.0.0)发送消息,代码如下 *我试过没有用户名和密码的\。当我在我的机器(localhost)上安装IBM MQ时尝试相同的代码时,它可以顺利运行。
private static void foo() throws JMSException {
Request request = new Request();
request.setRequestKey("11-12347");
request.setQueryString("This is a query string!");
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setHostName("192.168.1.107");
cf.setPort(1414);
cf.setAppName("WMQ Tester");
// cf.createConnection(sccsid, sccsid)
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setQueueManager("SanctionManager");
cf.setChannel("system.def.sanction");
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection("hanash", "hanash1");
MQQueueSession session = (MQQueueSession) connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("queue:///SanctionQueue");
MQQueueSender sender = (MQQueueSender) session.createSender(queue);
ObjectMessage objectMessage = session.createObjectMessage(request);
connection.start();
sender.send(objectMessage);
session.commit();
}
这给出了以下例外:
Exception in thread "main" com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: Failed to connect to queue manager 'SanctionManager' with connection mode 'Client' and host name '192.168.1.107(1414)'.
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.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:595)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:215)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:422)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:8475)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:7814)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl._createConnection(JmsConnectionFactoryImpl.java:299)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:236)
at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6024)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:136)
at com.dgbi.cre.MQSample.foo(MQSample.java:135)
at com.dgbi.cre.MQSample.main(MQSample.java:63)
Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2195' ('MQRC_UNEXPECTED_ERROR').
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203)
... 9 more
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ9204: Connection to host '192.168.1.107(1414)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2195;AMQ6047: Conversion not supported. [1=720,5=???]],3=192.168.1.107(1414),5=RemoteConnection.initSess]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2280)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1285)
at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:376)
at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:563)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:355)
... 8 more
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ6047: Conversion not supported. [1=720,5=???]
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1282)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:863)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:409)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:305)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:146)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1721)
... 12 more
Caused by: java.io.UnsupportedEncodingException: 720
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1268)
... 17 more
这个例外是什么意思?我该如何解决?
答案 0 :(得分:2)
例外中的关键错误是:
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ6047: Conversion not supported. [1=720,5=???]
Caused by: java.io.UnsupportedEncodingException: 720
这似乎是以下APAR中记录的IBM MQ v9.0.0.0中的已知问题:
此APAR已在9.0.0.1中修复。我建议你使用9.0.0.3,这是当前的LTS(长期支持)版本。
如果您查看APAR并与您的问题进行比较,则区别在于您要连接到使用CCSID 720(MSDOS ARABIC)设置的远程队列管理器。问题是您使用的Java JRE不支持此CCSID,并且由于存在缺陷,客户端不会尝试将CCSID重新协商为JRE支持的CCSID,并且连接因2195错误而失败。
答案 1 :(得分:0)
从JoshMC回答,看完后:
IT17154: Java client fails to connect to z/OS with exception 'AMQ6047: conversion not supported' in a non-IBM Java runtime
解决该问题的一种方法是使用IBM Java版本来构建应用程序。 (我实际上是这样做的。)