views:

315

answers:

3

Hi,

I want to use JMS to connect to IBM MQ. How do i specify the queuemanager, the channel and other properties ?

A: 

the best way is to use the command line. It is a lot of fun. You could download the command reference book from http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/csqzaj05.pdf

If your MQ server is running on a windows machine, you could optionally use a MQExplorer and configure it graphically.

Arun Manivannan
A: 

Hi Anand,

Here's a tutorial that may help:

Also, be sure to use the docs for the right version of WMQ. V7.0 is current and v6.0 is supported until September 2011. Whichever you are using, look at the Using Java manual for the right version:

v6.0 manual
v7.0 manual

T.Rob
+1  A: 

Using JNDI for connectionFactory/destinations lookups, provide the InitialContext with the following properties:

java.naming.provider.url=<ip>:<port, default is 1414>/<channel name, default channel is SYSTEM.DEF.SVRCONN>
java.naming.factory.initial=com.ibm.mq.jms.context.WMQInitialContextFactory
java.naming.security.authentication=none
java.naming.security.credentials=
java.naming.security.principal=

using WAS (Websphere Application Server) queues, the properties would be as follows:

java.naming.provider.url=iiop://<ip>:<port, the defualt is 2809>
java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory
java.naming.security.authentication=none
java.naming.security.credentials=
java.naming.security.principal=

The rest would be as follows:

Properties config = new Properties();
config.load(new FileInputStream("connectionConfig.properties"));// this file would contain the properties above
InitialContext context = new InitialContext(config);
ConnectionFactory factory = (ConnectionFactory) context.lookup("ConnectionFactory");// connection factory name
Destination destination = (Destination) context.lookup("destination");// queue/topic name
Ahmad