JMS client without JNDI

Hi Friends,

I am using JMS to interact with a remote MQ server on a Himalaya box. The MQ Admin objects on the server have not been published thru JNDI and I cannot use a look up scheme. I am trying to write a non JNDI client to examine messages on a queue. I have the samples from the MQ installation for that, but will I be able to use this client remotely? Is JNDI a MUST for a remote client? If so can any one explain how to use the com.sun.jndi.fscontext.RefFSContextFactory class? It would be great if anyone can provide code!!

Advanced Thanks,

Ram

[585 byte] By [m_ansram] at [2007-9-26 1:44:51]
# 1

You do not need to use JNDI for MQSeries.

Here' some code fragments. What you need to do is set the transport type, the Queue Manager

on the remote machine and the host name to connect remotely.

import javax.jms.*;

import com.ibm.mq.*;

import com.ibm.mq.jms.*;

try {

factory = new MQQueueConnectionFactory();

((MQQueueConnectionFactory)factory).setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);

((MQQueueConnectionFactory)factory).setQueueManager("QM_dev04");

((MQQueueConnectionFactory)factory).setHostName("dev04");

}

catch ( Exception e ) {

}

To use FSContextFactory -

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");

env.put(Context.PROVIDER_URL, "file://C:/...");

make sure that fscontext.jar and providerutil.jar are in your classpath

shirish_wagh at 2007-6-29 2:40:41 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Thanks..

The code did work, but when I tried to create a consumer like

qconn.createConnectionConsumer( q, null, ssp,batchSize);

I get an exception trace

2001.07.24 23:48:23 MQJMS1016E an internal error

has occurred. Please contact your system administrator. Detail: com.ibm.mq.MQExc

eption: Completion Code 2, Reason 2232

Exception in thread "main" javax.jms.JMSException: MQJMS2003: failed to disconne

ct queue manager

at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironm

ent.java:418)

at com.ibm.mq.jms.MQSession.close(MQSession.java:430)

at com.ibm.mq.jms.MQQueueAgent.getQueueAgent(MQQueueAgent.java:216)

at com.ibm.mq.jms.MQConnectionConsumer.<init>(MQConnectionConsumer.java:

216)

at com.ibm.mq.jms.MQConnectionConsumer.<init>(MQConnectionConsumer.java:

107)

at com.ibm.mq.jms.MQQueueConnection.createConnectionConsumer(MQQueueConn

ection.java:598)

at examples.jms.queue.ASFClient1.main(ASFClient1.java, Compiled Code)

The above call worked when I set the host name to localhost(I have an MQ server running locally as well)

Any ideas?

Thanks,

Ram

m_ansram at 2007-6-29 2:40:41 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...