[rabbitmq-discuss] RabbitMQ JMS Client

Steve Powell steve at rabbitmq.com
Wed Oct 23 17:13:44 BST 2013


Hi Jonathan,

Although The JMS Client for vFabric RabbitMQ (RJMS) doesn't supply a JNDI provider
it is quite happy using Destinations and ConnectionFactorys from JNDI. You will have to
write an admin application to populate your JNDI space (create these objects using
the RJMS client and the com.rabbitmq.jms.admin package).

Then once in you can retrieve connections and destinations from the JNDI in an RJMS 
app in the normal way.

The admin objects are Serializable and Referenceable as needed by the JNDI 
create/store/retrieve mechanisms.

Having said that, it should be possible for you to create and use the ConnectionFactory
and Destinations directly created by this API.

> I tried to get a connectionfactory from
> ObjectFactory.createConnectionFactory(Reference ref, Name name), with no
> luck.


An ObjectFactory is used by JNDI to create an object from a Reference. We produce a
reference (on demand) when JNDI stores an object, and JNDI recreates the object using
a Reference when you retrieve it. 

createConnectionFactory and createDestination are methods on RMQObjectFactory, 
which is presumably what you used but I wonder where you got the Reference argument
from?

To create a ConnectionFactory directly, first instantiate a RMQConnectionFactory:
	new RMQConnectionFactory()

set the host/port/etc individually, or use the setUri(String) method like this:
	setUri("amqp://uid:pass@host.name:port/vhost")
(the RabbitMQ site tells you what you can put in the AMQP scheme and how, the
standard RabbitMQ defaults apply),

and then createConnection() will do the rest (or createQueueConnection or 
createTopicConnection). You can provide the userid/password pair on the
createConnection(String,String) method call instead if you prefer.

After you get a connection, you can create a Session and createQueue(QUEUE_NAME) to 
create a Queue destination on the fly, or else you can create a Destination (with
various parameter options) with a new RMQDestination(…) constructor and use it
directly.

Let me know how it goes.

I'm keen to know how hard you find it to work your way through this, and any
feedback should be passed through your support channel, or email me directly
on steve at rabbitmq.com. This mailing list continues to be for general queries.

Steve Powell  [Cell: +44-7815-838-558] [RabbitMQ, Pivotal]
“L’enfer, c’est les autres.” Sartre

On 23 Oct 2013, at 15:09, Jonathan Skrzypek <jonathan.skrzypek at gs.com> wrote:

> Hi,
> 
> I'm trying to test the JMS Client for vFabric RabbitMQ.
> My understanding is that the JMS implementation in this client doesn't use
> the classic JNDI/lookup way of doing things in the JMS world. 
> Instead you have to use an ObjectFactor to create and register your factory.
> 
> I couldn't find java samples showing how to use the client. 
> I know there is a reference app but it's using the Play Framework Scala.
> 
> I tried to get a connectionfactory from
> ObjectFactory.createConnectionFactory(Reference ref, Name name), with no
> luck.
> I get a factory, but get a non-explicit exception when trying to call
> createConnection(), like :
> Exception occurred: com.rabbitmq.jms.util.RMQJMSException: tcp://broker:port
> 
> Is there a simple java sample anywhere ? Has somebody been able to build the
> usual connectionfactory->connection->session->producer/consumer object tree
> ?
> 
> Regards.
> 
> 
> 
> --
> View this message in context: http://rabbitmq.1065348.n5.nabble.com/RabbitMQ-JMS-Client-tp30766.html
> Sent from the RabbitMQ mailing list archive at Nabble.com.
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss



More information about the rabbitmq-discuss mailing list