You can use the command line to create and configure JMS.
Before you begin
- Open a command window.
- 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
- Run this command to set up the environment:
- Locate and open the JMSAdmin.config file.
- In the JMSAdmin.config file:
- Revise the INITIAL_CONTEXT_FACTORY parameter
to this definition:
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
- 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.
- 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
- Run this command to define the queue, where
MyQueue is
the queue name. def q (MyQueue) queue (MyQueue)
- 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)
- 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.