The objective of this document is to provide step-by-step instructions for configuring and running simple JMS Point-to-Point (P2P) and Pub/Sub applications in WebSphere MQ V7 for Windows.
Pre-requistes:
Class Path setup:
set MQ_JAVA_DATA_PATH=C:\Program Files (x86)\IBM\WebSphere MQ
set MQ_JAVA_INSTALL_PATH=C:\Program Files (x86)\IBM\WebSphere MQ\Java
set MQ_JAVA_LIB_PATH=C:\Program Files (x86)\IBM\WebSphere MQ\Java\lib64;C:\Program Files (x86)\IBM\WebSphere MQ\Java\lib
set MQ_JRE_PATH=C:\Program Files (x86)\IBM\WebSphere MQ\java\jre
set 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
Run java command on prompt to confirm:
1. Using Jadmin tool :
Create at dirctory in C or D drive with the name called JNDI-Directory.
C:\JNDI-Directory
a) Create a directory where the JMS configuration objects will be located in a file name ".bindings".
For example, in Windows, you can create the following subdirectory in the same directory where the other MQ objects are stored:
b) Copy the JMSAdmin.config file from its default location into C:\ The default file in Windows is located at:
C:\Program Files\IBM\WebSphere MQ\java\bin\JMSAdmin.config
You need to copy the JMSAdmin.config file:
Copy "C:\Program Files\IBM\WebSphere MQ\java\bin\JMSAdmin.config" C:\JMSAdmin.config
1) Modify C:\JMSAdmin.config
These 2 variables need to be properly specified in the config file.
2) INITIAL_CONTEXT_FACTORY
The following is common for UNIX and Windows and it indicates that a file will be used:
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
PROVIDER_URL=file:/C:/JNDI-Directory
Create a batch file called "myJMSAdmin.bat" that has this one line:
+ begin
"%MQ_JAVA_INSTALL_PATH%\bin\JMSAdmin" -cfg C:\JMSAdmin.config
+ end
This batch file will invoke the JMSAdmin tool using the JMSAdmin.config that was copied and modified under C:\
Ensure that the myJMSAdmin.bat is in a directory under PATH.
e) Start the myJMSAdmin batch file:
C:\> myJMSAdmin.bat
You will see the following. Notice the prompt: InitCtx>
Licensed Materials - Property of IBM
5724-H72, 5655-R36, 5724-L26, 5655-L82
(c) Copyright IBM Corp. 2008 All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
Starting Websphere MQ classes for Java(tm) Message Service Administration
Page 15 of 38
InitCtx>
Creation of physical objects (Queue and Topic) in the queue manager:
The following were used in Windows:
Queue Manager name: QM
Host: angelito.x.com
Port: 1414
$ runmqsc QM
define ql(Q1)
define topic(T1) topicstr('TOPIC1')
Configuration in Windows via MQ Explorer:
This chapter describes how to create a Connection Factory, a Queue and a Topic object into the JNDI via the MQ Explorer in Windows.
Start the MQ Explorer and the desired queue manager.
In this example, the queue manager is called: QM_ANGELITO
Scroll down to the bottom and select: JMS Administered Objects
Do right Click and select "Add Initial Context …"
In the dialog window for "Add Initial Context", specify:
Where is the JNDI namespace located?
(x) File System
JNDI Namespace location
Bindings directory: C:\var\mqm\JNDI-Directory
Accept the defaults and click Finish
Notice that this initial context location will be shown in the right panel:
In the left panel, expand the entry for the newly added initial context:
Let's create a Connection Factory for the new initial context.
Click on Connection Factories -> New -> Connection Factory …
Specify the name, such as: CF1
Click
Click Next.
Accept the default Type of "Connection Factory"
In case that you want "Queue Connection Factory", this is the panel where you can specify it.
The default value for the Transport is Bindings.
Because this document is trying to illustrate Client mode, then change to:
MQ Client
Click Next
You will see the following dialog with several tabs.
For this example, there are no changes in the General tab:
In the Connection tab, enter:
Base queue manager: QM_ANGELITO
Connection list: the hostname address and the port number
Notice that the channel to be used is by default:
SYSTEM.DEF.SVRCONN
Notice that this new Connection Factory will be listed in the right panel.
Let's create the Destination Queue Q1:
In the Create Destination, specify:
Name: Q1
Type: Queue
Click Next.
You will see:
Click Next.
Then enter the name of the physical queue in the queue manager, in this case it is the same name: Q1
Let's create the Topic T1
In
In the Create Destination, specify:
Name: T1
Type: Topic
Click Next
Click Next
Enter the Topic String: TOPIC1
Click Finish
Now you can proceed to the next chapter.
Running simple JMS samples provided with MQ V7 - Windows:
MQ V7 ships 2 very useful JMS samples that use the JNDI:
JmsJndiConsumer.java
JmsJndiProducer.java
In Windows, they are located at:
C:\Program Files\IBM\WebSphere MQ\tools\jms\samples
Run below commands:
C:\Program Files (x86)\IBM\WebSphere MQ\tools\jms\samples>java JmsJndiProducer -i file:C:/JNDI-Directory -c CF -d JMSQ
Run this command on two or three command prompts and see the result.
C:\Program Files (x86)\IBM\WebSphere MQ\tools\jms\samples>java JmsJndiConsumer -i file:C:/JNDI-Directory -c CF -d JMSQ