I am trying to get a MQQueueConnection object from MQQueueConnectionFactory object. I have copied my code snippet below.
MQConnectionFactory factory = new MQQueueConnectionFactory(); // calls to factory.setQueueManager, setPort, setHostName etc., // ... QueueConnection conn = ((MQQueueConnectionFactory)factory).createQueueConnection(); I am finding this "createQueueConnection()" returning an object of type "javax.jms.QueueConnection". But what I need is an "com.ibm.mq.jms.MQQueueConnection" object.
QueueConnection is a JMS inteface, and com.ibm.mq.jms.MQQueueConnection its implementing class. The recommended way is to use the interface; see, for example, the Sun tutorial for details. If, for some reason, you need the implementing class, you can downcast the interface reference.
Joined: Mar 22, 2006
Thank you very much. I wanted to move to MQ implemented classes from JMS API. I downcasted the code and it works!
Does it work? I think you should use JNDI to lookup a ConnectionFactory instead of new one by yourself. Some information from javax.jms.ConnectionFactory "Although the interfaces for administered objects do not explicitly depend on the Java Naming and Directory Interface (JNDI) API, the JMS API establishes the convention that JMS clients find administered objects by looking them up in a JNDI namespace. "
Jianfeng Qian<br />SCJP 1.4, SCBCD 5.0(beta)
subject: IBM MQ :: getting MQQueueConnection object