![]() |
MDB Simple Sample Application |
Configuring IBM WebSphere Messaging Queue (MQ) for JMS
This document describes how to configure IBM WebSphere Messaging Queue (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
- Configuring Sun ONE Application Server
- Registering JMS Resources with Sun ONE Application Server
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
- Set 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.
If you have not yet created a queue manager named mqseries.queue.manager, create and start the queue manager as follows:
Log on your system as the mqm user or as a user who is a member of mqm group.
Create local queues.On Windows 2000, you can also log on you system as user who belongs to the administrator group.
Create a queue manager named mqseries.queue.manager.
Start the queue manager.
- crtmqm -q mqseries.queue.manager
- strmqm
Start MQSC command session.
- runmqsc
Note The MQSC command session doesn't have an input prompt.
Once you are in MQSC command session, define local queues as follows:
Stop and exit the MQSC command session by typing end.
- define qlocal (ASQUEUE)
Create a configuration file.
Create the JMS administered objects which will be used by the Sun ONE sample applications.
- 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
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 4. If the file is not in the current directory, 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.
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
On Solaris, create a subcontext named jms at the command prompt InitCtx>. For example:
On Windows 2000, do not create the jms subcontext.
- InitCtx> define ctx(jms)
On Solaris, verify the defined objects using the following commands:
- For MDB Sample application, enter the following commands:
- InitCtx> define qcf(jms/MyQcf) qmgr(mqseries.queue.manager)
- InitCtx> define q(jms/MyQueue) qmgr(mqseries.queue.manager) queue(ASQUEUE)
On Windows 2000, verify the defined objects using the following commands:
InitCtx> change ctx(jms)
InitCtx> display ctx
you should receive an output similar to the one shown below:
Contents of InitCtx
.bindings java.io.File
a MyQueue com.ibm.mq.jms.MQQueue
a MyQcf com.ibm.mq.jms.MQQueueConnectionFactory3 Object(s)
0 Context(s)
3 Binding(s), 2 Administered
Exit the the WebSphere MQ JMS Administration Tool using the command end. For example:
InitCtx>display ctx
you should receive 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
- InitCtx> end
Configuring Sun ONE Application Server
In this section, you will add MQ jar and MQ java libraries to the Sun ONE Application Server using the web-based Administration Tool.
From your web browser, access the Sun ONE Administration Tool at http://<host>:<admin_port>
On the left frame, navigate the tree by clicking on the following folders:
- Where <host> is the machine on which the application server is installed, and <admin_port> is the server administration port.
On the right frame, click on the JVM Settings tab and then the Path Settings link
- AppServer Instances->server1
Enter the following files in the Classpath Suffix text box:
Where <MQ_HOME> is WebSphere MQ installation home on Windows 2000.
- 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
In the Native Library Path Suffix text box, type the following:
Where <MQ_HOME> is WebSphere MQ installation home.
- On Solaris:
/opt/mqm/java/lib
- On Windows 2000:
<MQ_HOME>/java/lib
To propagate these modifications to the server, do the following:
Stop and start the server instance.
- Click the General tab and click on Apply Changes button.
Registering JMS Resources with Sun ONE Application Server
Now that you have created the JMS resources in Step 5 of Configuring WebSphere MQ, you must register these resources with Sun ONE Application Server via the use of external-jndi resources. The procedure is as follows:
Run the asadmin utility in multimode. For example:
Set global parameters so that you will not have to enter them for every sub command. For example:
- <AS_HOME>/bin/asadmin multimode asadmin utility in multimode
- Where <AS_HOME> is Sun ONE application server installation home.
Create external jndi external resources.
- 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).
List the external jndi resources to verify the resources you have created. For example:
- For the MDB sample application, create one external jndi resources with the resource type of javax.jms.QueueConnectionFactory, and one with the resource type of javax.jms.Queue as follows:
- asadmin>create-jndi-resource --jndilookupname <qcf_jndi_lookup-name> --resourcetype javax.jms.QueueConnectionFactory --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=<directory_path>:java.naming.security.authentication=none <qcf_jndi_name>
- asadmin>create-jndi-resource --jndilookupname <q_jndi_lookup-name> --resourcetype javax.jms.Queue --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=<directory_path> <q_jndi_name>
- Where <qcf_jndi_lookup-name> and <qcf_jndi_name> should be replaced with jms/MyQcf.
- <q_jndi_lookup-name> and <q_jndi_name> should be replaced with jms/MyQueue
- <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/MyQcf --resourcetype javax.jms.QueueConnectionFactory --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=file\:///export/JMSRes:java.naming.security.authentication=none jms/MyQcf
- asadmin>create-jndi-resource --jndilookupname jms/MyQueue --resourcetype javax.jms.Queue --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url=file\:///export/JMSRes jms/MyQueue
- On Windows 2000:
asadmin>create-jndi-resource --jndilookupname jms/MyQcf --resourc etype javax.jms.QueueConnectionFactory --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property ja va.naming.provider.url=file\:///D\:/JMSRes:java.naming.security.authentication=none jms/MyQcf
- asadmin>create-jndi-resource --jndilookupname jms/MyQueue --resourcetype javax.jms.Queue --factoryclass com.sun.jndi.fscontext.RefFSContextFactory --enabled=true --property java.naming.provider.url =file\:///D\:/JMSRes jms/MyQueue
Reconfigure the server instance to make sure the changes you made have been propagated to server. For example:
- asadmin>list-jndi-resources server_instance
- asadmin>reconfig instance_name
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated July 10, 2002