This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes IBM MQ :: getting MQQueueConnection object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "IBM MQ :: getting MQQueueConnection object" Watch "IBM MQ :: getting MQQueueConnection object" New topic

IBM MQ :: getting MQQueueConnection object

Balaji VR
Ranch Hand

Joined: Mar 22, 2006
Posts: 76

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 "" object.

Please help me.

[ March 20, 2007: Message edited by: Balaji VR ]

Bala<br />SCJP 1.4 98%<br />SCBCD 1.3 -- 88%
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
QueueConnection is a JMS inteface, and 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.
Balaji VR
Ranch Hand

Joined: Mar 22, 2006
Posts: 76
Thank you very much. I wanted to move to MQ implemented classes from JMS API. I downcasted the code and it works!

conn = (MQQueueConnection)((MQQueueConnectionFactory)factory).createQueueConnection();

Jianfeng Qian
Ranch Hand

Joined: Jan 25, 2005
Posts: 83
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)
I agree. Here's the link:
subject: IBM MQ :: getting MQQueueConnection object
It's not a secret anymore!