Search code examples
javajmsjndiibm-mq

How can I get an existing JMS queue?


I feel like this is probably a pretty simple question, but this is my first foray into JMS, so I am a little unsure.

I am trying to write to an existing JMS queue (and then read from another queue), for which I know the queue name, host, queue manager, and channel. How do I get a reference to this queue in the form of a javax.jms.Destination object?

All of the examples I have found involve calling javax.jms.Session.createQueue(String), but since this queue already exists, I don't want to create another one, right? Or am I misunderstanding what is going on?

If it matters, I am using the com.ibm.msg.client.jms driver.

Thanks!


Solution

  • Normally, the container in which your application runs will bind the Queue in its naming service. An application in the container can look it up with JNDI and use it.