tags:

views:

184

answers:

1

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!

+4  A: 

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.

erickson
Thanks! Is it possible to access the queue from a standalone java program? Eventually, I will be using the Queue from a Java EE application, but right now I'm trying to just experiment get more familiar with JMS. If it isn't possible to do this, I can probably skip this step, but I would like to have some code that interacts with the Queue without all the other complexity in my application.
pkaeding
Usually it is possible to do this from a standalone application, but the details depend a lot on the JMS provider you are using. For example, many app servers provide a JNDI provider and JMS driver that you can use in an application outside the app server itself to establish a connection.
erickson