如何编写脚本来复制IBM MQ MQExplorer对象创建行为?

Rob*_*ley 1 ibm-mq

使用IBM MQ 8.0.0.9我无法MQExplorer从命令行复制GUI操作的行为.

使用MQExplorer我创建:

  1. 标题管理器,标题为testQueueManager使用默认值
  2. 标题为testQueue使用默认值的队列
  3. 标题为testChannel使用默认值的服务器连接通道
  4. 使用*- >用户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
Run Code Online (Sandbox Code Playgroud)

这是我运行它时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.
Run Code Online (Sandbox Code Playgroud)

我希望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
Run Code Online (Sandbox Code Playgroud)

这个问题似乎指向jar文件的区别,但我在两种情况下都使用相同的客户端.似乎默认情况下命令行与默认值之间必须存在差异MQExplorer.

Rob*_*ker 5

我看不到您在脚本中为队列管理器创建侦听器或在crtmqm命令(-p 1414)上设置默认侦听器.在MQ Explorer中,创建队列管理器的其中一个步骤具有在端口1414上创建侦听器的默认设置.

解决这个问题:

将您的crtmqm命令更改为: crtmqm -p 1414 $qmgr

要么

将以下MQSC命令添加到runmqsc命令:

DEFINE LISTENER(LISTENER) TRPTYPE(TCP) PORT(1414)
START LISTENER(LISTENER)
Run Code Online (Sandbox Code Playgroud)