I have a generic standalone JMS application which works with following JMS providers WebSphere, HornetQ and ActiveMq. I pass Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER
In order to get JMS working with RabbitMQ, you have to enable the plugin rabbitmq_jms_topic_exchange.
You can download it following the directions in this site (You'll need to login):
https://my.vmware.com/web/vmware/details?downloadGroup=VFRMQ_JMS_105&productId=349
rabbitmq-plugins enable rabbitmq_jms_topic_exchangerabbitmq-plugins listBear in mind that you'll have to create a .bindings file in order to JNDI found your registered objects. This is an example of the content of it:
ConnectionFactory/ClassName=com.rabbitmq.jms.admin.RMQConnectionFactory
ConnectionFactory/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory
ConnectionFactory/RefAddr/0/Content=jms/ConnectionFactory
ConnectionFactory/RefAddr/0/Type=name
ConnectionFactory/RefAddr/0/Encoding=String
ConnectionFactory/RefAddr/1/Content=javax.jms.ConnectionFactory
ConnectionFactory/RefAddr/1/Type=type
ConnectionFactory/RefAddr/1/Encoding=String
ConnectionFactory/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory
ConnectionFactory/RefAddr/2/Type=factory
ConnectionFactory/RefAddr/2/Encoding=String
# Change this line accordingly if the broker is not at localhost
ConnectionFactory/RefAddr/3/Content=localhost
ConnectionFactory/RefAddr/3/Type=host
ConnectionFactory/RefAddr/3/Encoding=String
# HELLO Queue
HELLO/ClassName=com.rabbitmq.jms.admin.RMQDestination
HELLO/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory
HELLO/RefAddr/0/Content=jms/Queue
HELLO/RefAddr/0/Type=name
HELLO/RefAddr/0/Encoding=String
HELLO/RefAddr/1/Content=javax.jms.Queue
HELLO/RefAddr/1/Type=type
HELLO/RefAddr/1/Encoding=String
HELLO/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory
HELLO/RefAddr/2/Type=factory
HELLO/RefAddr/2/Encoding=String
HELLO/RefAddr/3/Content=HELLO
HELLO/RefAddr/3/Type=destinationName
HELLO/RefAddr/3/Encoding=String
And then... finally... the code:
Properties environmentParameters = new Properties();
environmentParameters.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
environmentParameters.put(Context.PROVIDER_URL, "file:/C:/rabbitmq-bindings");
namingContext = new InitialContext(environmentParameters);
ConnectionFactory connFactory = (ConnectionFactory) ctx.lookup("ConnectionFactory");