Previous Topic: Defining the JNDI Connectivity ParametersNext Topic: Configure the Agent Plug-in for WebSphere MQ


Store the JNDI Information Using JMSAdmin

You use the JMSAdmin utility to store the JNDI information about the system where WebSphere MQ is installed.

Note: The instructions in this procedure use a file-based JNDI. If you are using another JNDI provider, you will need to adapt these steps.

Follow these steps:

  1. Source the code in the MQ environment.
  2. Create a directory on your file system for a file-based JNDI, if applicable.
  3. Create a JMSAdmin configuration file by copying and editing the JMSAdmin.config file that is located in the WebSphere MQ installation directory.
  4. Edit the two lines in the JMSAdmin configuration file that correspond to the following parameters:

    Note: For a file-based JNDI, the INITIAL_CONTEXT_FACTORY and PROVIDER_URL are the only parameters that you need.

  5. Invoke the JMSAdmin utility with the configuration file you edited.

    The InitCtx> prompt appears indicating that you are connected to the initial context factory and provider URL you defined in the configuration file.

    Note: For information about the JMSAdmin utility, see the WebSphere MQ JMS Administration Tool.

  6. Define the JMS connection factory object using the following command:
    DEFINE QCF(connectionfactory) TRANSPORT(CLIENT) QMGR(queuemanager) HOSTNAME(host) PORT(port)
    
  7. Define the JMS destination using the following command:
    DEFINE Q(destination) QMGR(queuemanager) QUEUE(queuename)
    
  8. Verify your definition using the following command:
    DISPLAY CTX
    

    The JMSAdmin utility displays lines for your two definitions.

  9. Type END to complete the definition and exit the utility.

    The JNDI information is stored.

Example: Store the Information for a File-based JNDI on UNIX

This example creates a subdirectory /var/mqm/fsjndi on a UNIX file system. The subdirectory contains a .bindings file that stores the WebSphere MQ queue connection information.

Follow these steps:

  1. Source the code into the shell environment on UNIX:
    ./opt/mqm/java/bin/setjmsenv
    
  2. Create a directory named fsjndi on the file system:
    cd /var/mqm
    mkdir fsjndi
    
  3. Create a JMSAdmin configuration file named MyJMSAdmin.config:
    cp $MQ_JAVA_INSTALL_PATH/bin/JMSAdmin.config MyJMSAdmin.config
    
  4. Edit the JMSAdmin configuration file for the initial context factory and provider URL lines as follows:
    INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
    PROVIDER_URL=file:/var/mqm/fsjndi
    
  5. Comment out any of the other settings in the JMSAdmin configuration file.
  6. Invoke the JMSAdmin utility with the JMSAdmin configuration file:
    MQ_JAVA_INSTALL_PATH/bin/JMSAdmin -cfg MyJMSAdmin.config
    
  7. Define the JMS connection factory object using the following command:
    DEFINE QCF(MY_QUEUE_CF) TRANSPORT(CLIENT) QMGR(queue.manager) HOSTNAME(somehost) PORT(1414)
    
  8. Define the JMS destination using the following command:
    DEFINE Q(MY_QUEUE) QMGR(queue.manager) QUEUE(MY.QUEUE)
    
  9. Verify your definition using the following command:
    DISPLAY CTX
    

    The JMS Admin utility displays the following lines.

    .bindings		java.io.File
    MY_QUEUE_CF		com.ibm.mq.jms.MQQueueConnectionFactory
    MY_QUEUE		com.ibm.mq.jms.MQQueue
    
  10. Type END to complete the definition and exit the utility.

Note: You can copy the entire fsjndi subdirectory to anywhere you want on any computer you want. Update the Provider URL parameter that is used during queue connections to the corresponding location.