ibm-mq - 如何编写脚本来复制 IBM MQ MQExplorer 对象创建行为?
问题描述
使用 IBM MQ 8.0.0.9
,我无法MQExplorer
从命令行复制 GUI 操作的行为。
使用MQExplorer
我创建:
testQueueManager
使用默认值命名的队列管理器testQueue
使用默认值命名的队列testChannel
使用默认值命名的服务器连接通道*
使用-> 用户 id的地址映射的通道认证记录client
Java 客户端可以毫无问题地连接到该实例。
下面的 shell 脚本应该可以复制上面的内容。我知道我授予了不必要的权限,这纯粹是为了连接测试。
#!/bin/sh
set -eu
user=client
pass=password
qmgr="testQueueManager"
channel="testChannel"
queue="testQueue"
useradd "$user" && echo "$user":password | chpasswd
/opt/mqm/bin/crtmqm "$qmgr"
/opt/mqm/bin/strmqm "$qmgr"
/opt/mqm/bin/runmqsc "$qmgr" << EOF
DEFINE QLOCAL('$queue')
DEFINE CHANNEL('$channel') CHLTYPE(SVRCONN) TRPTYPE(TCP)
SET CHLAUTH('$channel') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(MAP) MCAUSER('$user') ACTION(ADD)
EOF
/opt/mqm/bin/setmqaut -m "$qmgr" -t qmgr -p client +all
/opt/mqm/bin/setmqaut -m "$qmgr" -n "$channel" -t channel -p client +all
/opt/mqm/bin/setmqaut -m "$qmgr" -n "$queue" -t queue -p client +all
这是我运行 shell 脚本时的输出:
WebSphere MQ queue manager created.
Directory '/var/mqm/qmgrs/testQueueManager' created.
The queue manager is associated with installation 'Installation1'.
Creating or replacing default objects for queue manager 'testQueueManager'.
Default objects statistics : 79 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
WebSphere MQ queue manager 'testQueueManager' starting.
The queue manager is associated with installation 'Installation1'.
5 log records accessed on queue manager 'testQueueManager' during the log replay phase.
Log replay for queue manager 'testQueueManager' complete.
Transaction manager state recovered for queue manager 'testQueueManager'.
WebSphere MQ queue manager 'testQueueManager' started using V8.0.0.9.
5724-H72 (C) Copyright IBM Corp. 1994, 2015.
Starting MQSC for queue manager testQueueManager.
1 : DEFINE QLOCAL('testQueue')
AMQ8006: WebSphere MQ queue created.
2 : DEFINE CHANNEL('testChannel') CHLTYPE(SVRCONN) TRPTYPE(TCP)
AMQ8014: WebSphere MQ channel created.
3 : SET CHLAUTH('testChannel') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(MAP) MCAUSER('client') ACTION(ADD)
AMQ8877: WebSphere MQ channel authentication record set.
3 MQSC commands read.
No commands have a syntax error.
All valid MQSC commands were processed.
The setmqaut command completed successfully.
The setmqaut command completed successfully.
The setmqaut command completed successfully.
我期望连接到相同项目的 Java 客户端具有相同的行为。我得到的是一个讨厌的堆栈跟踪,如下所示:
org.apache.felix.log.LogException: com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: Failed to connect to queue manager 'testQueueManager' with connection mode 'Client' and host name '127.0.0.1(1414)'.
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:423)
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:6016)
at com.ibm.mq.jms.MQConnectionFactory.createConnection(MQConnectionFactory.java:6041)
... 7 more
Caused by: org.apache.felix.log.LogException: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2009' ('MQRC_CONNECTION_BROKEN').
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203)
... 15 more
Caused by: org.apache.felix.log.LogException: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2009;AMQ9204: Connection to host '127.0.0.1(1414)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2009;AMQ9208: Error on receive from host '/127.0.0.1:1414 (localhost)'. [1=-1,2=ffffffff,3=/127.0.0.1:1414 (localhost),4=TCP]],3=127.0.0.1(1414),5=RemoteConnection.receiveTSH]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2276)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1288)
at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:376)
at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:560)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:356)
... 14 more
Caused by: org.apache.felix.log.LogException: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2009;AMQ9208: Error on receive from host '/127.0.0.1:1414 (localhost)'. [1=-1,2=ffffffff,3=/127.0.0.1:1414 (localhost),4=TCP]
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.receiveTSH(RemoteConnection.java:3291)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1411)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:1007)
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:155)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1724)
... 18 more
这个问题似乎指向一个 jar 文件的差异,但我在这两种情况下都使用相同的客户端。似乎命令行与MQExplorer
.
解决方案
我看不到您在脚本中为队列管理器创建侦听器或在 crtmqm 命令 ( -p 1414
) 上设置默认侦听器。在 MQ Explorer 中,创建队列管理器的步骤之一具有在端口 1414 上创建侦听器的默认设置。
要解决此问题:
将您的 crtmqm 命令更改为:crtmqm -p 1414 $qmgr
或者
将以下 MQSC 命令添加到您的 runmqsc 命令:
DEFINE LISTENER(LISTENER) TRPTYPE(TCP) PORT(1414)
START LISTENER(LISTENER)
推荐阅读
- angularjs - Angularjs 如何从一个控制器切换到另一个控制器?
- python - 在python中打印一个数字模式,最后没有空格和换行
- python - 尝试使用 Python 和 BeautifulSoup 来提取精确值
- python - 使用 openCV 和 python 检测图像中的模式和数字
- python-3.x - 减少 Python 中 IF 语句的数量
- android - 使用 play-services-vision 检测人脸并提取该信息
- php - WordPress 在自定义插件中将会话数据从产品页面带到购物车页面?
- php - 根据不包括透明的颜色查找表减少图像颜色
- android - 使用 getActionBar.setTitle() 时应用程序崩溃;同时扩展 FragmentActivity
- google-cloud-platform - Ansible 中的 gsutil 权限