2

我正在尝试通过一种非常标准的机制将消息发布到远程 JMS 队列:

TopicConnection tc = null;
TopicSession ts = null;
TopicPublisher tp = null;
Properties p = new Properties();
String providerUrl = "iiop://servername:9810";
String contextFactory = "com.ibm.websphere.naming.WsnInitialContextFactory".trim();
p.put(javax.naming.Context.PROVIDER_URL, providerUrl );
p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, contextFactory );
InitialContext ct = new InitialContext(p);

{                       
Topic topic = (Topic)ct.lookup( "jms/customer_event" );
TopicConnectionFactory tcf = (TopicConnectionFactory)ct.lookup( "jms/TopicFactory2" );
tc = tcf.createTopicConnection();
....
..
..
}

现在, Topic 和 TopicConnectionFactory 查找很好,但是当涉及到 时tcf.createTopicConnection(),它会抛出:

javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'servername:QMGR1'
Inner exception(s):
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2059
java.net.ConnectException: Connection refused: connect

我打开了 MQ 资源管理器,主题在远程队列管理器上。TopicCoonectionFactory 是否TopicFactory2也应该驻留在队列管理器上?因为它没有。错误的原因可能是什么?

4

2 回答 2

2

When connecting, the details of host, port and channel must be correct. If the host or port are wrong, then the TCP socket is refused. If the channel name is wrong, then the queue manager will refuse the connection and close the socket. It is possible that you have all the details correct but that the listener on the queue manager is not running.

If the connection is getting as far as the queue manager then you will have an error in the [WMQ Install dir]/qmgrs/[QMgr name]/errors/AMQERR01.LOG file. If the connection gets to WMQ but cannot resolve the queue manager's name or specifies the wrong QMgr then the error will be in [WMQ Install dir]/errors/AMQERR01.LOG. If there is no entry in either of these then the connection isn't making it to WMQ and you need to check the listener or the network.

于 2012-08-01T00:11:21.833 回答
0

2059 连接被拒绝很可能是网络错误或 MQ 服务器主机名和/或端口中的类型。仔细检查您在 WebSphere 中的配置和网络连接。

ConnectException 的 JavaDoc 也说明了这个http://docs.oracle.com/javase/6/docs/api/java/net/ConnectException.html

Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the connection was refused remotely (e.g., no process is listening on the remote address/port).

于 2012-08-01T00:01:45.377 回答