Sun Java System logo      Previous     
JMS Sample Application


Chapter 1   Configuring IBM TM WebSphere MQ for JMS


This document describes how to configure IBM TM WebSphere MQ (formerly MQSeries) V 5.3 for Java Messaging Services (JMS) on Solaris and Windows 2000.

This document contains the following sections:



Configuring WebSphere MQ for JMS

This section describes the steps to configure the JMS resources using the MQ command line utilities and the WebSphere MQ JMS Administration Tool.

For more information about the WebSphere MQ JMS administration tool, please read Chapter 5: Using the WebSphere MQ JMS Administration Tool from the document titled "Using Java". The document can be found online at: http://publibfp.boulder.ibm.com/epubs/html/csqzaw09/csqzaw09tfrm.htm

  1. Setting environment variables

    On Solaris, before the administrative interface can be used, it's necessary to set the following environment variables as described below:

    setenv MQ_HOME /opt/mqm/

    setenv MQ_JAVA_INSTALL_PATH /opt/mqm/java

    setenv MQ_JAVA_DATA_PATH /var/mqm

    setenv LD_LIBRARY_PATH /opt/mqm/java/lib

    setenv PATH ${PATH}:$MQ_JAVA_INSTALL_PATH/bin

    setenv CLASSPATH /opt/mqm/java/lib/com.ibm.mq.jar: /opt/mqm/java/lib/com.ibm.mqjms.jar: /opt/mqm/java/lib/connector.jar: /opt/mqm/java/lib/jms.jar: /opt/mqm/java/lib/fscontext.jar: /opt/mqm/java/lib/providerutil.jar: /opt/mqm/java/lib/jndi.jar: /opt/mqm/java/lib/jta.jar: /opt/mqm/java

    On Windows 2000, the environment variables are automatically set when WebSphere MQ is installed.

  1. If you have not yet created a queue manager named mqseries.queue.manager, create and start the queue manager as follows:

    1. Log on your system as the mqm user or as a user who is a member of mqm group.

      On Windows 2000, you can also log on you system as user who belongs to the administrator group.

    2. Create a queue manager named mqseries.queue.manager.

      crtmqm -q mqseries.queue.manager

    3. Start the queue manager.

      strmqm

  2. Create a configuration file.

    The sample applications use the JNDI file system to store and lookup the administered objects. The configuration parameters should be set as follows:

    INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory

    PROVIDER_URL=file:///[drive]:<directory_path>

    SECURITY_AUTHENTICATION=none

    Where <directory_path> must be an existing path to a directory. The directoy will be used as a storage and it could be any directory accessible by users who are in mqm group.

    An example of the configuration file is as follows:

    INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory

    On Solaris:
    PROVIDER_URL=file:///export/JMSRes

    On Windows 2000:
    PROVIDER_URL=file:///D:/JMSRes

    SECURITY_AUTHENTICATION=none

  3. Create the JMS administered objects which will be used by the Sun Java (tm) System sample applications.

    1. Execute the MQSeries JMS administrative tool as follows:

      On Solaris:

      $MQ_JAVA_INSTALL_PATH/bin/JMSAdmin -v -cfg <configuration_file>

      On Windows 2000:

      %MQ_JAVA_INSTALL_PATH%\bin\JMSAdmin -v -cfg <configuration_file>

      Where <configuration_file> is the name of the file created in Step 3. If the file is not in the current directoy, the whole path must be specified.



Note On Solaris, if an error occurs, it ispossible that the current user cannot access the /opt/mqm directory. If this is the case, enable user access by executing chmod +rx /opt/mqm.



    1. On Solaris, create a subcontext named jms at the command prompt InitCtx>. For example:

      InitCtx> define ctx(jms)

      On Windows 2000, do not create the jms subcontext.

    2. Create administered objects.

      For the JMS Topic Simple Sample application, enter the following commands:

      InitCtx> define tcf(jms/sampleTCF) qmgr(mqseries.queue.manager)

      InitCtx> define t(jms/sampleTopic) topic(ASTOPIC)

    3. On Solaris, verify the defined objects using the following commands:

      InitCtx> change ctx(jms)

      InitCtx> display ctx

      You should get an output similar to the one shown below:

      Contents of InitCtx

      .bindings   java.io.File
      a sampleTCF1   com.ibm.mq.jms.MQTopicConnectionFactory
      a sampleTopic   com.ibm.mq.jms.MQTopic

      3 Object(s)
      0 Context(s)
      3 Binding(s), 2 Administered

      On Windows 2000, verify the defined objects using the following commands:

      InitCtx>display ctx

      You should get an output similar to the one shown below:

      Contents of InitCtx

      .bindings   java.io.File

      1 Object(s)
      0 Context(s)
      1 Binding(s), 0 Administered

    4. Exit the the WebSphere MQ JMS Administration Tool using the command end. For example:

      InitCtx> end

For more information about the WebSphere MQ JMS administration tool, please read Chapter 5: Using the WebSphere MQ JMS Administration Tool from the document titled "Using Java". The document can be found online at: http://publibfp.boulder.ibm.com/epubs/html/csqzaw09/csqzaw09tfrm.htm

Setting up the Broker to run the WebSphere MQ JMS



If you haven't installed the SuportPac MA0C to use WebSphere MQ JMS implementation of JMS publish/subcribe, please refer to Installing IBM TM WebSphere MQ document for where to download and how to install the SupportPac MA0C. If you have already installed the SupportPact, do the following steps to set up the the broker to run the WebSphere MQ JMS:

  1. Create the WebSphere MQ JMS system queues by executing the command:

    On Solraris:

    cd $MQ_JAVA_INSTALL_PATH/bin

    runmqsc mqseries.queue.manager < MQJMS_PSQ.mqsc

    On Windows 2000:

    cd %MQ_JAVA_INSTALL_PATH%\bin

    runmqsc mqseries.queue.manager < MQJMS_PSQ.mqsc

  2. Verify that the broker is running

    dspmqbrk -m mqseries.queue.manager

    If a message reports that the broker is not running, start the broker using the command:

    strmqbrk -m mqseries.queue.manager

For more information about setting up the broker to run the WebSphere MQ JMS, please read Chapter 11: Programming publish/subscribe applications from the document titled "Using Java". The document can be found online at: http://publibfp.boulder.ibm.com/epubs/html/csqzaw09/csqzaw09tfrm.htm



Configuring Sun Java (tm) System Application Server



In this section, you will add MQ jar and MQ java libraries to the Sun Java (tm) System Application Server using the web-based Administration Tool.

  1. From your web browser, access the Sun Java (tm) System Administration Tool at http://<host>:<admin_port>

    Where <host> is the machine on which the application server is installed, and <admin_port> is the server administration port.

  2. On the left frame, navigate the tree by clicking on the following folders:

    AppServer Instances->server1

  3. On the right frame, click on the JVM Settings tab and then the Path Settings link

  4. Enter the following files in the Classpath Suffix text box:

    On Solaris:

    /opt/mqm/java/lib/com.ibm.mq.jar

    /opt/mqm/java/lib/com.ibm.mqjms.jar

    /opt/mqm/java/lib

    On Windows 2000:

    <MQ_HOME>/java/lib/com.ibm.mq.jar

    <MQ_HOME>/java/lib/com.ibm.mqjms.jar

    <MQ_HOME>/java/lib

    Where <MQ_HOME> is WebSphere MQ installation home on Windows 2000.

  5. In the Native Library Path Suffix text box, type the following:

    On Solaris:

    /opt/mqm/java/lib

    On Windows 2000:

    <MQ_HOME>/java/lib

    Where <MQ_HOME> is WebSphere MQ installation home.

  6. Click the Save button.

  7. To propagate these modifications to the server, do the following:

    Click the General tab and click on Apply Changes button.

  8. Stop and start the server instance


Registering JMS Resources with Sun Java (tm) System Application Server

Now that you have created the JMS resources in Step 5 of Configuring WebSphere MQ, you must register these resources with Sun Java (tm) System Application Server via the use of external-jndi resources. The procedure is as follows:

  1. Run the asadmin utility in multimode. For example:

    <AS_HOME>/bin/asadmin multimode asadmin utility in multimode

    Where <AS_HOME> is Sun Java (tm) System application server installation home.

  2. Set global parameters so that you will not have to enter them for every sub command. For example:

    asadmin>export AS_ADMIN_USER=<admin_username> AS_ADMIN_PASSWORD=<admin_password> AS_ADMIN_HOST=<host> AS_ADMIN_PORT=<adminserver_port> AS_ADMIN_INSTANCE=<instance_name>

    Where <admin_username> is application server admin user name, <admin_password> is the admin password, <host> is the machine on which the application server is installed, <adminserver_port> is admin server port of the application server, and <instance_name> is the application server instance name (e.g. server1).

  3. Create external jndi external resources.

    For the JMS Topic Simple sample application, create one external jndi resources with the resource type of javax.jms.TopicConnectionFactory, and one with the resource type of javax.jms.Topic as follows:

    asadmin>create-jndi-resource --jndilookupname jms/sampleTCF --resourcetype javax.jms.TopicConnectionFactory --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=<directory_path>:java.naming.security.authentication=none jms/sampleTCF

    asadmin>create-jndi-resource --jndilookupname jms/sampleTopic --resourcetype javax.jms.Topic --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=<directory_path> jms/sampleTopic

    Where <directory_path> is the file system set to the PROVIDER_URL parameter in Create a configuration file. You must use an escape character in front of the colon (:) in the directory path.

    Below are examples of how to create jndi resources on Solaris and Windows 2000.

    On Solaris:

    asadmin>create-jndi-resource --jndilookupname jms/sampleTCF --resourcetype javax.jms.TopicConnectionFactory --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=file\:///export/JMSRes:java.naming.security.authentication=none jms/sampleTCF

    asadmin>create-jndi-resource --jndilookupname jms/sampleTopic --resourcetype javax.jms.Topic --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=file\:///export/JMSRes jms/sampleTopic

    On Windows 2000:

    asadmin>create-jndi-resource --jndilookupname jms/sampleTCF --resourc etype javax.jms.TopicConnectionFactory --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property ja va.naming.provider.url=file\:///D\:/JMSRes:java.naming.security.authentication=none jms/sampleTCF

    asadmin>create-jndi-resource --jndilookupname jms/sampleTopic --resourcetype javax.jms.Topic --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url =file\:///D\:/JMSRes jms/sampleTopic

  4. List the external jndi resources to verify the resources you have created. For example:

    asadmin>list-jndi-resources server_instance

  5. Reconfigure the server instance to make sure the changes you made have been propagated to server. For example:

    asadmin>reconfig instance_name

After you have finished installing and configuring WebSphere MQ, you may proceed to Compiling and Assembling the Sample Application or Deploying the Sample Application.


Previous     
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.

Last Updated July 10, 2002