简体   繁体   中英

I cant read the messages from IBM MQ using java

I am using IBM MQ version 7.5 (trial version)

I have created a two queue managers (QM1 and QM2)

Under the QM1:
port : 1421
Queues: q1(local queue)
channel: ch1 (receiver)

Under the QM2:
port :1422
Queues:q2(transmission queue),q3(remote queue)
channel:ch1 (sender)

I can send the messages through QM2 's queue q3 to QM1 's queue q1 . I can also receive and browse the messages through the q2 .

But when I use the java to read the messages from q1 I have an error

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 

When I check with the IBM site they said it can cause the due to the below reasons
http://www-01.ibm.com/support/docview.wss?uid=swg21226703

  1. A firewall has terminated the connection.
  2. An IOException caused the socket to be closed.
  3. An explicit action caused the socket to be closed by one end.
  4. The queue manager is offline.
  5. The maximum number of channels allowed by the queue manager are already open.
  6. A configuration problem in the Queue Connection Factory (QCF).

But all of the above are looks good in my system. what I missing , Kindly let me know.

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

Adding:

version of the jar :

C:\\Program Files (x86)\\IBM\\WebSphere MQ\\java\\lib>java -cp ./com.ibm.mq.jar com.ibm.mq.MQJavaLevel
Name: WebSphere MQ classes for Java
Version: 7.5.0.2
Level: p750-002-130627
Build Type: Production

After changing the channel I have received the below error

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

channel: ch1 (receiver)

MQEnvironment.channel="ch1";

An MQ Client application cannot use a RECEIVER channel to connect to a queue manager. The application needs to connect to a SVRCONN channel.

Secondly, it is a bad idea to use lowercase names for MQ objects. MQ will automatically uppercase names that are not in quotes. So, to avoid problems, use uppercase names.

Finally I have resolve the issue

  • By creating a svrconn channel instead of using default one SYSTEM.DEF.SVRCONN ( I have used TEST.SVRCONN )
  • And go to : channel -> Channel Authentication Records -> Delete the Block User list

By following the above method I can resolve the issue. Now I can read the messages from Java application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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