Using the command line to configure JMS

You can use the command line to create and configure JMS.

Before you begin

  1. Open a command window.
  2. Navigate to the <mqm instalation directory>/java/bin folder, such as /opt/mqm/java/bin directory.

About this task

Follow these steps to configure JMS from the command line.

Procedure

  1. Run this command to set up the environment:
    setjmsenv
  2. Locate and open the JMSAdmin.config file.
  3. In the JMSAdmin.config file:
    1. Revise the INITIAL_CONTEXT_FACTORY parameter to this definition:
      INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
    2. Ensure that the PROVIDER_URL parameter is defined, for example: PROVIDER_URL= file:/opt/mqm/JNDI-Directory. If it does not exist, ensure that you create the directory, otherwise the JMSAdmin command will fail.
  4. Run this command to open the JMS Administration command line:
    JMSAdmin
    If the JMSAdmin command fails with an error like java.lang.NoClassDefFoundError: com.ibm.mq.jms.admin.JMSAdmin, you might need to set the CLASSPATH variable pointing to the mqjms.jar file. For example, export CLASSPATH=/opt/mqm/java/lib/com.ibm.mqjms.jar
  5. Run this command to define the queue, where MyQueue is the queue name.
     def q (MyQueue) queue (MyQueue)
  6. Run this command to define the Queue Connection Factory, where myQcf is the queue connection factory, MY.CHANNEL is the existing channel name, host is the host name for this WebSphere® MQ instance, and MyQueueManager is the queue manager.
    def qcf(myQcf) transport(CLIENT) channel(MY.CHANNEL) host(9.30.203.110) port(1416) qmgr(MyQueueManager)
  7. Enter and run this command to close the initial context mode:
    end
    Note: When everything runs successful, a .bindings file is created in the configured JNDI_Directory directory. To verify the creation of the file, run the ls -la /var/mqm/JNDI_DIRECTORY command.