繁体   English   中英

我无法使用Java从IBM MQ中读取消息

[英]I cant read the messages from IBM MQ using java

我正在使用IBM MQ版本7.5(试用版)

我创建了两个队列管理器(QM1和QM2)

在QM1下:
港口:1421
队列:q1(本地队列)
频道: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

  1. 防火墙已终止连接。
  2. IOException导致套接字被关闭。
  3. 显式操作导致套接字被一端关闭。
  4. 队列管理器离线。
  5. 队列管理器允许的最大通道数已打开。
  6. 队列连接工厂(QCF)中的配置问题。

但是以上所有内容在我的系统中看起来都不错。 我想念的是什么,请告诉我。

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();
}

添加:

版本的罐子:

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 --------------------------------------------------------

频道:ch1(接收器)

MQEnvironment.channel = “CH1”;

MQ Client应用程序不能使用RECEIVER通道连接到队列管理器。 该应用程序需要连接到SVRCONN通道。

其次,对MQ对象使用小写名称是个坏主意。 MQ将自动将大写的名称括在引号中。 因此,为避免出现问题,请使用大写名称。

终于我解决了这个问题

  • 通过创建一个svrconn通道而不是使用默认的一个SYSTEM.DEF.SVRCONN (我使用过TEST.SVRCONN
  • 并转到:channel-> Channel Authentication Records->删除阻止用户列表

通过按照上述方法,我可以解决此问题。 现在,我可以从Java应用程序中读取消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM