从 Java 客户端连接到 IBM MQ 失败,MQJE001:完成代码“2”,原因“2035”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39405911/
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
Connecting to IBM MQ from Java client is failing with MQJE001: Completion Code '2', Reason '2035'
提问by Mayuran
I have a IBM MQ version 7.5 installation in windows 7. I have created a queue manager, channel and listener using the following commands.
我在 Windows 7 中安装了 IBM MQ 7.5 版。我使用以下命令创建了一个队列管理器、通道和侦听器。
//CREATE THE QUEUE MANAGER
crtmqm.exe PG3RT1
//START THE QUEUE MANAGER AS INTERACTIVE
strmqm.exe -si PG3RT1
//CONNECT AS SCRIPT CONSOLE
runmqsc.exe PG3RT1
//CREATE THE CHANNEL TO APPLICATION CONNECTIVITY
DEFINE CHANNEL(PG3RT1.CHANNEL) CHLTYPE(SVRCONN) TRPTYPE(TCP)
//CREATE THE LISTENER
DEFINE LISTENER(LISTENER.PG3RT1) TRPTYPE(TCP) PORT(1414)
//START THE LISTENER
START LISTENER(LISTENER.PG3RT1)
Now i am trying to connect to the Queue Manager using following java client. connection is rejected with the following error.
现在我正在尝试使用以下 java 客户端连接到队列管理器。连接因以下错误而被拒绝。
15:06:52.175 [localhost-startStop-1] ERROR c.b.c.s.s.m.MQUtil - MQJE001: Completion Code '2', Reason '2035'.
com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2035'.
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:230)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:553)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:593)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:96)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:198)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:893)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:780)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:729)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:177)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:745)
at com.bcs.cas.sach.simulator.mq.MQUtil.init(MQUtil.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
Can anyone advise why the connection is failing. Do i need to enable remote administration on the queue manager?
谁能告诉为什么连接失败。我需要在队列管理器上启用远程管理吗?
Following is the code fragement i used for connection
以下是我用于连接的代码片段
public void init(){
MQEnvironment.hostname = hostName;
MQEnvironment.port = Integer.valueOf(port);
MQEnvironment.channel = serverChannelName;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);
LOGGER.info("queueManagerName: " + queueManagerName);
LOGGER.info("hostName: " + hostName);
LOGGER.info("serverChannelName: " + serverChannelName);
LOGGER.info("port: " + port);
//initialize the connection pool
MQPoolToken token = MQEnvironment.addConnectionPoolToken();
try {
mqQueueManager = new MQQueueManager(queueManagerName, MQEnvironment.properties);
LOGGER.info("mqQueueManager: " + mqQueueManager);
} catch (MQException e) {
LOGGER.error(e.getMessage(), e);
}
}
回答by Tim McCormick
MQRC 2035 is MQRC_NOT_AUTHORIZED. The reason this was returned can be found in the AMQERR log on the queue manager.
MQRC 2035 是 MQRC_NOT_AUTHORIZED。返回的原因可以在队列管理器的 AMQERR 日志中找到。
As CHLAUTH hasn't been configured, and is on by default, I expect you're not able to connect as you're not passing the CHLAUTH rules.
由于尚未配置 CHLAUTH,并且默认情况下处于启用状态,因此我希望您无法连接,因为您没有通过 CHLAUTH 规则。
回答by Ramachandran.A.G
It is quite likely that this is an authorization issue. The easiest is to look at the return code and interpret
这很可能是授权问题。最简单的就是看返回码并解释
mqrc 2035 returns MQRC_NOT_AUTHORIZED
mqrc 2035 returns MQRC_NOT_AUTHORIZED
One of the reasons for it could be permissions. This can be resolved either by setting the right privilges on the QueueManager (setmqaut) , then on the channel enable the user with you are connecting to MQ to authorize as explained here. Post this you can use the code to connect by adding userId to the MQEnvironment and go
其原因之一可能是权限。这可以通过设置上的QueueManager(的setmqaut)右privilges得到解决,则通道上启用与您连接到MQ授权的解释,用户在这里。发布此您可以通过将 userId 添加到 MQEnvironment 并使用代码进行连接
You can also refer this technotefor information.
您还可以参考此技术说明以获取信息。