Java MQ:与主机的连接被拒绝 | 渠道协商失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21830631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MQ: Connection to host rejected | Channel negotiation failed
提问by EN20
Hello I have one big problem with connecting to IBM WebSphere MQ using JMS
I use:
您好,我在使用 JMS 连接到 IBM WebSphere MQ 时遇到了一个大问题
:
- Win 7
- JDK 1.7
- IBM WebSphere MQ server 7.5.0.2
- GlassFish 4.0
- 赢7
- JDK 1.7
- IBM WebSphere MQ 服务器 7.5.0.2
- 玻璃鱼 4.0
I make one QueueManager named test1
and one queue in that named test1q
and one channel for negotiation named test1channel
我命名了一个 QueueManagertest1
和该命名中的一个队列,test1q
以及一个名为的协商通道test1channel
My code is here:
我的代码在这里:
StandaloneSender s = new StandaloneSender();
try{
s.send(“hello word”);
}catch (Exception e){
e.printStackTrace();
}
StandaloneSender.java
独立发件人.java
import javax.jms.Message;
import javax.jms.QueueConnection;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.NamingException;
public class StandaloneSender {
private P2PUtils utils;
private QueueConnection connection;
private QueueSession session;
private QueueSender sender;
public void send(String message) throws NamingException, JMSException, IOException {
StandaloneSender sender = new StandaloneSender();
sender.connect();
sender.sendMessage(message);
sender.disconnect();
}
public StandaloneSender() {
utils = new P2PUtils();
}
private void connect() throws NamingException, JMSException {
connection = utils.getConnection();
session =
connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
sender = session.createSender(utils.getQueue());
System.out.println("Sender started.");
}
private void sendMessage(String text) throws JMSException {
Message message = session.createTextMessage(text);
sender.send(message);
System.out.println(
"Sent message <"
+ text
+ "> with ID <"
+ message.getJMSMessageID()
+ ">");
}
private void disconnect() throws JMSException {
sender.close();
session.close();
connection.close();
System.out.println("Sender stopped.");
}
}
P2PUtils.java
P2PUtils.java
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.NamingException;
public class P2PUtils extends JmsUtils {
private static final String QCF_NAME = "test1";
private static final String QUEUE_NAME = "test1q";
public QueueConnection getConnection() throws NamingException, JMSException {
Context context = getInitialContext();
QueueConnectionFactory qcf =
(QueueConnectionFactory) context.lookup(QCF_NAME);
return qcf.createQueueConnection();
}
public Queue getQueue() throws NamingException {
Context context = getInitialContext();
return (Queue) context.lookup(QUEUE_NAME);
}
}
JmsUtils.java
JmsUtils.java
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class JmsUtils {
private static final String CF_CLASS_NAME = "com.ibm.mq.jms.context.WMQInitialContextFactory";
private static final String WMQ_URL = "localhost:1414/SYSTEM.DEF.SVRCONN";
protected Context getInitialContext() throws NamingException {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, CF_CLASS_NAME);
props.put(Context.PROVIDER_URL, WMQ_URL);
return new InitialContext(props);
}
}
But I have got this exception from glassfish:
但是我从 glassfish 那里得到了这个例外:
[2014-02-17T16:35:25.286+0330] [glassfish 4.0] [SEVERE] [] [] [tid: _ThreadID=25 _ThreadName=Thread-4] [timeMillis: 1392642325286] [levelValue: 1000] [[
javax.naming.ServiceUnavailableException: Unable to connect to the target queue manager localhost:1414/SYSTEM.DEF.SVRCONN [Root exception is com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2539'.]
at com.ibm.mq.jms.context.MQContext.<init>(MQContext.java:196)
at com.ibm.mq.jms.context.WMQInitialContextFactory.getInitialContext(WMQInitialContextFactory.java:29)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at com.surena.MQ.JmsUtils.getInitialContext(JmsUtils.java:17)
at com.surena.MQ.P2PUtils.getConnection(P2PUtils.java:16)
at com.surena.MQ.StandaloneSender.connect(StandaloneSender.java:32)
at com.surena.MQ.StandaloneSender.send(StandaloneSender.java:22)
at com.surena.servlet.MainServlet.doGet(MainServlet.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access0(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:744)
Caused by: com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2539'.
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:247)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:588)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:630)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:107)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:205)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:911)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:799)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:750)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:157)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:757)
at com.ibm.mq.pcf.PCFAgent.connect(PCFAgent.java:230)
at com.ibm.mq.pcf.PCFAgent.<init>(PCFAgent.java:163)
at com.ibm.mq.pcf.PCFMessageAgent.<init>(PCFMessageAgent.java:140)
at com.ibm.mq.jms.context.MQContext.<init>(MQContext.java:183)
... 39 more
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2539;AMQ9204: Connection to host 'localhost(1414)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2539;AMQ9503: Channel negotiation failed. [3=SYSTEM.DEF.SVRCONN]],3=localhost(1414),5=RemoteConnection.initSess]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2053)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1226)
at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:311)
at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:337)
at com.ibm.mq.MQSESSION.MQCONNX_j(MQSESSION.java:924)
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:236)
... 52 more
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2539;AMQ9503: Channel negotiation failed. [3=SYSTEM.DEF.SVRCONN]
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1111)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:727)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:400)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:299)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:164)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1598)
... 57 more]]
And this from IBM MQ
这来自 IBM MQ
2/17/2014 14:41:51 - Process(3924.1) User(MUSR_MQADMIN) Program(runmqlsr.exe)
Host(PROGRAMMER1) Installation(Installation1)
VRMF(7.5.0.2)
AMQ6118: An internal WebSphere MQ error has occurred (20006047)
EXPLANATION:
An error has been detected, and the MQ error recording routine has been called.
ACTION:
Use the standard facilities supplied with your system to record the problem
identifier and to save any generated output files. Use either the MQ Support
site: http://www.ibm.com/software/integration/wmq/support/, or IBM Support
Assistant (ISA): http://www.ibm.com/software/support/isa/, to see whether a
solution is already available. If you are unable to find a match, contact your
IBM support center. Do not discard these files until the problem has been
resolved.
----- amqxfdcp.c : 867 --------------------------------------------------------
2/17/2014 14:41:51 - Process(3924.1) User(MUSR_MQADMIN) Program(runmqlsr.exe)
Host(PROGRAMMER1) Installation(Installation1)
VRMF(7.5.0.2)
AMQ6184: An internal WebSphere MQ error has occurred on queue manager test1
.
EXPLANATION:
An error has been detected, and the WebSphere MQ error recording routine has
been called. The failing process is process 3924.
ACTION:
Use the standard facilities supplied with your system to record the problem
identifier and to save any generated output files. Use either the MQ Support
site: http://www.ibm.com/software/integration/wmq/support/, or IBM Support
Assistant (ISA): http://www.ibm.com/software/support/isa/, to see whether a
solution is already available. If you are unable to find a match, contact your
IBM support center. Do not discard these files until the problem has been
resolved.
I used all jar file that included in MQ installation directory
please help me.
我使用了 MQ 安装目录中包含的所有 jar 文件,
请帮助我。
采纳答案by Morag Hughson
From your exception from glassfish I've picked out the interesting bits:-
从 glassfish 的例外中,我挑选了一些有趣的部分:-
javax.naming.ServiceUnavailableException: Unable to connect to the target
queue manager localhost:1414/SYSTEM.DEF.SVRCONN [Root exception is
com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2539'.
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2539;
AMQ9204: Connection to host 'localhost(1414)' rejected.
[1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2539;
AMQ9503: Channel negotiation failed. [3=SYSTEM.DEF.SVRCONN]],
3=localhost(1414),5=RemoteConnection.initSess]
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2539;
AMQ9503: Channel negotiation failed. [3=SYSTEM.DEF.SVRCONN]
There are various hints here for you. The first is the MQRC return code 2539. You can look this up using the mqrc command line tool that comes with IBM MQ. Just type mqrc 2539
and it will report:-
这里有各种提示给你。第一个是 MQRC 返回码 2539。您可以使用 IBM MQ 随附的 mqrc 命令行工具进行查找。只需输入mqrc 2539
,它就会报告:-
2539 0x000009eb MQRC_CHANNEL_CONFIG_ERROR.
Also we have a couple of error messages:-
我们还有一些错误消息:-
AMQ9204: Connection to host 'localhost(1414)' rejected.
AMQ9503: Channel negotiation failed. [3=SYSTEM.DEF.SVRCONN]
You can see the full error message description using the mqrc tool as well, just type mqrc AMQ9204
. So we're getting the idea here that your network connection (channel) was not working right and the queue manager didn't like it for some reason. The next thing is to see what the queue manager had to say about it, as you did. In you error log you say you saw:-
您也可以使用 mqrc 工具查看完整的错误消息描述,只需键入mqrc AMQ9204
. 所以我们在这里了解到您的网络连接(通道)工作不正常,队列管理器出于某种原因不喜欢它。下一步是看看队列管理器对此有何评论,就像您所做的那样。在您的错误日志中,您说您看到了:-
2/17/2014 14:41:51 - Process(3924.1) User(MUSR_MQADMIN) Program(runmqlsr.exe)
Host(PROGRAMMER1) Installation(Installation1)
VRMF(7.5.0.2)
AMQ6118: An internal WebSphere MQ error has occurred (20006047)
Now this is indicating that there is likely an FDC file that has been cut as well which will give more details, but there is also another error code that you can look up, again with the mqrc tool. Type in mqrc 0x20006047
and it will report:-
现在这表明可能有一个 FDC 文件也已被剪切,这将提供更多详细信息,但您还可以再次使用 mqrc 工具查找另一个错误代码。输入mqrc 0x20006047
,它会报告:-
536895559 0x20006047. xecX_E_CONV_NOT_SUP
This suggests that it was unable to cope with data conversion between your client and the queue manager. The FDC file will give you more details.
这表明它无法处理您的客户端和队列管理器之间的数据转换。FDC 文件将为您提供更多详细信息。