Testing IBM MQ on IBM i with JMS

How you test IBM MQ with JMS with and without JNDI


Testing JMS without JNDI using the IVTRun sample

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. Start the qshell, from the command line, by issuing the STRQSH command.
  3. Use the cd command to change directory as follows:
    cd /qibm/proddata/mqm/java/bin
    
  4. Run the script file:
    IVTRun -nojndi [-m qmgrname]
    

You receive output similar to the following example. Note that the copyright statements depend upon the versions of the products that we are using:

> IVTRun -nojndi -m ELCRTP19

Attaching Java program to
/QIBM/ProdData/mqm/java/lib/com.ibm.mqjms.JAR.
Attaching Java program to
/QIBM/ProdData/mqm/java/lib/jms.JAR.

5724-H72, 5724-B41, 5655-F10 (c) Copyright IBM Corp. 2011, 2020.
All Rights Reserved.
WebSphere MQ classes for Java(tm) Message Service 5.300
Installation Verification Test


Creating a QueueConnectionFactory
Creating a Connection
Creating a Session
Creating a Queue
Creating a QueueSender
Creating a QueueReceiver
Creating a TextMessage
Sending the message to SYSTEM.DEFAULT.LOCAL.QUEUE
Reading the message back again

Got message:
JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:c1d4d840c5d3c3d9e3d7f1f9404040403ccf041f0000c012
JMSTimestamp: 1020273404500
JMSCorrelationID:null
JMSDestination: queue:///SYSTEM.DEFAULT.LOCAL.QUEUE
JMSReplyTo: null
JMSRedelivered: false
JMS_IBM_PutDate:20040326
JMSXAppID:QP0ZSPWT STANLEY 170302
JMS_IBM_Format:MQSTR
JMS_IBM_PutApplType:8
JMS_IBM_MsgType:8
JMSXUserID:STANLEY
JMS_IBM_PutTime:13441354
JMSXDeliveryCount:1
A simple text message from the MQJMSIVT program
Reply string equals original string
Closing QueueReceiver
Closing QueueSender
Closing Session
Closing Connection
IVT completed OK
IVT finished
$>
$


Testing IBM MQ JMS client mode without JNDI

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 server connection channel is created, by issuing the following command:
    WRKMQMCHL CHLNAME( SYSTEM.DEF.SVRCONN ) CHLTYPE(*SVRCN)
    MQMNAME(QMGRNAME) 
    
  3. Verify that the listener is started for the correct port, by issuing the WRKMQMLSR command
  4. Start the qshell, from the command line, by issuing the STRQSH command.
  5. Verify that the CLASSPATH is correct by issuing the export command.
  6. Use the cd command to change directory as follows:
    cd /qibm/proddata/mqm/java/bin
    
  7. Run the script file:
    IVTRun -nojndi -client -m QMgrName -host hostname [-port port] [-channel channel] 
    

You receive output similar to the following example. Note that the copyright statements depend upon the versions of the products that we are using.

> IVTRun -nojndi -client -m ELCRTP19 -host ELCRTP19 -port 1414 -channel SYSTEM.DEF.SVRCONN

5724-H72, 5724-B41, 5655-F10 (c) Copyright IBM Corp. 2011, 2020.
All Rights Reserved.
WebSphere MQ classes for Java(tm) Message Service 5.300
Installation Verification Test


Creating a QueueConnectionFactory
Creating a Connection
Creating a Session
Creating a Queue
Creating a QueueSender
Creating a QueueReceiver
Creating a TextMessage
Sending the message to SYSTEM.DEFAULT.LOCAL.QUEUE
Reading the message back again

Got message:
JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:c1d4d840c5d3c3d9e3d7f1f9404040403ccf041f0000d012
JMSTimestamp: 1020274009970
JMSCorrelationID:null
JMSDestination: queue:///SYSTEM.DEFAULT.LOCAL.QUEUE
JMSReplyTo: null
JMSRedelivered: false
JMS_IBM_PutDate:20040326
JMSXAppID:MQSeries Client for Java
JMS_IBM_Format:MQSTR
JMS_IBM_PutApplType:28
JMS_IBM_MsgType:8
JMSXUserID:QMQM
JMS_IBM_PutTime:14085237
JMSXDeliveryCount:1
A simple text message from the MQJMSIVT program
Reply string equals original string
Closing QueueReceiver
Closing QueueSender
Closing Session
Closing Connection
IVT completed OK
IVT finished
$  


Testing IBM MQ JMS with JNDI

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)
Use the IVTRun sample test scriptCarry out the following procedure:
  1. Make the appropriate changes to the JMSAdmin.config file. To edit this file use the EDTF (Edit File) command from an IBM i command line
    EDTF '/qibm/proddata/mqm/java/bin/JMSAdmin.config'
    
    .
    1. To use LDAP for Weblogic, remove the comment from:
      INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory
      
    2. To use LDAP for WebSphere Application Server, remove the comment from:
      INITIAL_CONTEXT_FACTORY=com.ibm.ejs.ns.jndi.CNInitialContextFactory
      
    3. To test the file system, remove the comment from:
      INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
      
    4. Ensure that we have selected the correct PROVIDER_URL, by removing the comment from the appropriate line.
    5. Comment out all other lines using the # symbol.
    6. When you have completed all your changes, press F2=Save and F3=Exit.

  2. Start the qshell, from the command line, by issuing the STRQSH command.
  3. Verify that the CLASSPATH is correct by issuing the export command.
  4. Use the cd command to change directory as follows:
    cd /qibm/proddata/mqm/java/bin
    
  5. Start the IVTSetup script to create the administered objects (MQQueueConnectionFactory and MQQueue), by issuing the IVTSetup command.
  6. Run the IVTRun script by issuing the following command:
    IVTRun -url providerURL [-icf initCtxFact] 
    

You receive output similar to the following example. Note that the copyright statements depend upon the versions of the products that we are using.

> IVTSetup
+ Creating script for object creation within JMSAdmin
+ Calling JMSAdmin in batch mode to create objects
Ignoring unknown flag: -i

5724-H72 (c) Copyright IBM Corp. 2011, 2020. All Rights Reserved.
Starting WebSphere MQ classes for Java(tm) Message Service Administration

InitCtx>
InitCtx>
InitCtx>
InitCtx>
InitCtx>
Stopping MQSeries classes for Java(tm) Message Service Administration

+ Administration done; tidying up files
+ Done!
$
> IVTRun -url file:////tmp/mqjms -icf com.sun.jndi.fscontext.RefFSContextFactory

5724-H72 (c) Copyright IBM Corp. 2011, 2020. All Rights Reserved.
MQSeries classes for Java(tm) Message Service 
Installation Verification Test

Using administered objects, please ensure that these are available

Retrieving a QueueConnectionFactory from JNDI
Creating a Connection
Creating a Session
Retrieving a Queue from JNDI
Creating a QueueSender
Creating a QueueReceiver
Creating a TextMessage
Sending the message to SYSTEM.DEFAULT.LOCAL.QUEUE
Reading the message back again

Got message:
JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:c1d4d840c5d3c3d9e3d7f1f9404040403ccf041f0000e012
JMSTimestamp: 1020274903770
JMSCorrelationID:null
JMSDestination: queue:///SYSTEM.DEFAULT.LOCAL.QUEUE
JMSReplyTo: null
JMSRedelivered: false
JMS_IBM_Format:MQSTR
JMS_IBM_PutApplType:8
JMSXDeliveryCount:1
JMS_IBM_MsgType:8
JMSXUserID:STANLEY
JMSXAppID:QP0ZSPWT STANLEY 170308
A simple text message from the MQJMSIVT program
Reply string equals original string
Closing QueueReceiver
Closing QueueSender
Closing Session
Closing Connection
IVT completed OK
IVT finished
$
Parent topic: Set up IBM MQ on IBM i with Java and JMS