Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IBM MQ :: getting MQQueueConnection object

 
Balaji VR
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Please help me.

Thanks.
[ March 20, 2007: Message edited by: Balaji VR ]
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Balaji VR
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();

Thanks!
 
Jianfeng Qian
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic