This looks simple but I can't find a simple answer.
I want to open a connection to a remote JMS broker (IP and port are known), open a session to the a specific queue (name known) and post a message to this queue.
Is there any simple Java API (standard if possible) to do that ?
EDIT
Ok I understand now that JMS is a driver spec just like JDBC and not a communication protocol as I thought.
Given I am running in JBoss, I still don't understand how to create a JBossConnectionFactory.
EDIT
I actually gave the problem some thoughts (hmmm) and if JMS needs to be treated the same as JDBC, then I need to use a client provided by my MQ implementation. Since we are using SonicMQ for our broker, I decided to embed the sonic_Client.jar library provided with SonicMQ.
This is working in a standalone Java application and in our JBoss service.
Thanks for the help
Best Answer
You'll need to use JMS, create a
QueueConnectionFactory
and go from there. Exactly how you create theQueueConnectionFactory
will be vendor specific (JMS is basically a driver spec for message queues just as JDBC is for databases) but on IBM MQ it something like this:EDIT (following question edit)
The best way to access a remote queue, or any queue for that matter, is to add a
Queue
instance to the JNDI registry. For remote queues this is achieved using MBeans that add theQueue
instance when the server starts.Take a look at http://www.jboss.org/community/wiki/UsingWebSphereMQSeriesWithJBossASPart4, which while it's an example with IBM MQ, is essentially what you have to do to connect to any remote queue.
If you look at
jbossmq-destinations-service.xml
andorg.jboss.mq.server.jmx
you'll see the MBeans you need to create in relation to a JBoss queue.