Testing IBM MQ on IBM i with Java

How you test IBM MQ with Java using the MQIVP sample program.


Testing IBM MQ base Java

Carry out the following procedure:
  1. Verify that the queue manager is started, and that the state of the queue manager is ACTIVE, by issuing the following command:
    WRKMQM MQMNAME(QMGRNAME)
    
  2. Verify that the JAVA.CHANNEL server connection channel has been created by issuing the following command:
    WRKMQMCHL CHLNAME(JAVA.CHANNEL) CHLTYPE(*SVRCN) MQMNAME(QMGRNAME)
    
    1. If the JAVA.CHANNEL does not exist, issue the following command:
      CRTMQMCHL CHLNAME(JAVA.CHANNEL) CHLTYPE(*SVRCN) MQMNAME(QMGRNAME)
      

  3. Verify the queue manager listener is running for port 1414 or whichever port we are using, by issuing the WRKMQMLSR command.
    1. If no listener has been started for the queue manager, issue the following command:
      STRMQMLSR PORT(xxxx) MQMNAME(QMGRNAME)
      

Running the MQIVP sample test program

  1. Start the qshell, from the command line by issuing the command STRQSH
  2. Verify that the correct CLASSPATH is set by issuing the export command, and then issue the cd command as follows:
    cd /qibm/proddata/mqm/java/samples/wmqjava/samples
    
  3. Run the java program by issuing the following command:
    java MQIVP
    

We can press the ENTER key when prompted for:

  • Type of connection
  • IP address
  • Queue manager name

to use the default values. This verifies the product bindings, which can be found in the QMQMJAVA library. You receive output similar to the following example. Note that the copyright statement depends upon the version of the product that we are using.

> java MQIVP
MQSeries for Java Installation Verification Program
5724-H72 (C) Copyright IBM Corp. 2011, 2020. All Rights Reserved.
===========================================================

Please enter the IP address of the MQ server :>
Please enter the queue manager name :>
Attaching Java program to QIBM/ProdData/mqm/java/lib/connector.JAR.
Success: Connected to queue manager.
Success: Opened SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Put a message to SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Got a message from SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Closed SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Disconnected from queue manager


Tests complete -
SUCCESS: This MQ Transport is functioning correctly.
Press Enter to continue ...>
$ 


Testing IBM MQ Java client connection

We must specify the:

  • Connection type
  • IP address
  • Port
  • Server connection channel
  • Queue manager

You receive output similar to the following example. Note that the copyright statement depends upon the version of the product that we are using.

> java MQIVP
MQSeries for Java Installation Verification Program
5724-H72 (C) Copyright IBM Corp. 2011, 2020. All Rights Reserved.
===========================================================

Please enter the IP address of the MQ server :> x.xx.xx.xx
Please enter the port to connect to : (1414)> 1470
Please enter the server connection channel name :> JAVA.CHANNEL
Please enter the queue manager name :> KAREN01
Success: Connected to queue manager.
Success: Opened SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Put a message to SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Got a message from SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Closed SYSTEM.DEFAULT.LOCAL.QUEUE
Success: Disconnected from queue manager


Tests complete -
SUCCESS: This MQ Transport is functioning correctly.
Press Enter to continue ...>
$
Parent topic: Set up IBM MQ on IBM i with Java and JMS