我使用的是IBM MQ 7.5版(试用版)
我创建了两个队列管理器(QM1和QM2)
在QM1下:
港口:1421
队列:q1(本地队列)
channel:ch1(接收者)
在QM2下:
港口:1422
队列:q2(传输队列),q3(远程队列)
频道:ch1(发件人)
我可以通过 QM2 的队列 q3 将消息发送到 QM1 的队列 q1 。我还可以通过 q2 接收和浏览消息。
但是当我使用java从q1读取消息时,我有一个错误
MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
MQJE001: Completion Code 2, Reason 2009
当我向IBM网站查询时,他们说这可能是由于以下原因引起的 http://www-01.ibm.com/support/docview.wss?uid=swg21226703
但以上所有内容在我的系统中都很好看。我错过了,请告诉我。
public static void main(String[] args) throws MQException {
MQEnvironment.hostname="localhost";
MQEnvironment.channel="ch1";
MQEnvironment.port=1421;
MQQueueManager qMgr= new MQQueueManager("QM1");
MQQueue outputQueue =qMgr.accessQueue("q1", MQC.MQOO_INQUIRE | MQC.MQOO_BROWSE | MQC.MQOO_INPUT_AS_Q_DEF);
//Checking for messages in queue
int i=outputQueue.getCurrentDepth();
System.out.println("Number of messages in queue: "+i);
outputQueue.close();
qMgr.close();
qMgr.disconnect();
}
添加:
jar的版本:
C:\ Program Files(x86)\ IBM \ WebSphere MQ \ java \ lib> java -cp ./com.ibm.mq.jar com.ibm.mq.MQJavaLevel
名称:Java的WebSphere MQ类
版本:7.5.0.2
等级:p750-002-130627
构建类型:生产
更改频道后,我收到以下错误
----- amqrmrsa.c : 898 --------------------------------------------------------
10/20/2017 02:17:37 - Process(16340.40) User(MUSR_MQADMIN) Program(amqrmppa.exe)
Host(user1) Installation(Installation1)
VRMF(7.5.0.2) QMgr(Receiver)
AMQ9777: Channel was blocked
EXPLANATION:
The inbound channel 'SYSTEM.DEF.SVRCONN' was blocked from address '127.0.0.1'
because the active values of the channel matched a record configured with
USERSRC(NOACCESS). The active values of the channel were 'CLNTUSER(fresher)'.
ACTION:
Contact the systems administrator, who should examine the channel
authentication records to ensure that the correct settings have been
configured. The ALTER QMGR CHLAUTH switch is used to control whether channel
authentication records are used. The command DISPLAY CHLAUTH can be used to
query the channel authentication records.
----- cmqxrmsa.c : 926 --------------------------------------------------------
10/20/2017 02:17:37 - Process(16340.40) User(MUSR_MQADMIN) Program(amqrmppa.exe)
Host(user1) Installation(Installation1)
VRMF(7.5.0.2) QMgr(Receiver)
AMQ9999: Channel 'SYSTEM.DEF.SVRCONN' to host 'user1 (127.0.0.1)' ended
abnormally.
EXPLANATION:
The channel program running under process ID 16340(5348) for channel
'SYSTEM.DEF.SVRCONN' ended abnormally. The host name is 'user1
(127.0.0.1)'; in some cases the host name cannot be determined and so is shown
as '????'.
ACTION:
Look at previous error messages for the channel program in the error logs to
determine the cause of the failure. Note that this message can be excluded
completely or suppressed by tuning the "ExcludeMessage" or "SuppressMessage"
attributes under the "QMErrorLog" stanza in qm.ini. Further information can be
found in the System Administration Guide.
----- amqrmrsa.c : 898 --------------------------------------------------------
答案 0 :(得分:1)
频道:ch1(接收方)
MQEnvironment.channel = “CH1”;
MQ客户端应用程序无法使用RECEIVER通道连接到队列管理器。应用程序需要连接到SVRCONN通道。
其次,为MQ对象使用小写名称是个坏主意。 MQ将自动大写不在引号中的名称。因此,为避免出现问题,请使用大写名称。
答案 1 :(得分:0)
最后我解决了这个问题
- 通过创建svrconn频道而不是使用默认频道 SYSTEM.DEF.SVRCONN (我使用 TEST.SVRCONN )
- 转到:频道 - >频道验证记录 - >删除阻止用户列表
按照上述方法我可以解决问题。现在我可以从Java应用程序中读取消息。