In this post, I'll describe how to setup ActiveMQ as a JMS provider in WebSphere Application Server 7. We used ActiveMQ 5.2 with WAS 7.0.7 and had 1 topic connection factory (JNDI name TopicConnectionFactory) and a single topic (JNDI name jms/systemMessageTopic). Our ActiveMQ Message Broker was running locally on port 61620.
Before you start, take a look at your application and do the following - particularly if you're coming from an application server other than WebSphere:
First, you need to add the ActiveMQ JAR files to <WAS_ROOT>/lib/ext - Do not use the activemq-all JAR as this contains JMS implementation which will interfere with WebSphere's own classes. We added the following ActiveMQ libs:
- Remove any jndi.properties files as these we will be configuring JNDI within WAS
- Remove any activemq JARs from your webapp lib directory as we will add these to the WAS extension class loader
You should stop/start your application server at this point so the libraries get loaded.
Next, in the WAS admin console navigation tree, click "Resources -> JMS -> JMS Providers" . In the content pane click "New" and set the attributes as follows:
External initial context factory: org.apache.activemq.jndi.ActiveMQWASInitialContextFactory
External provider URL: tcp://localhost:61620
(nb. as you've added the ActiveMQ JARs to the lib/ext directory, you do not need to explicitly fill in the class path in the JMS provider.)
Once you've clicked OK to create the provider, from the same JMS Providers screen, click on the new "ActiveMQ provider" and then click on "Custom Properties". In this screen you need to create entries that will be used to initialise the ActiveMQInitialContextFactory. You need to create Java.lang.String properties, one which lists your connection factories, and one property for each of your topics/queues. For our setup, we added:
- java.naming.connectionFactoryNames = TopicConnectionFactory (if you have other types of connection factory, you should supply these here too, comma seperated)
- java.naming.topic.jms.systemMessageTopic = jms/systemMessageTopic (if you have queues, use java.naming.queue here)
Finally, you need to configure your connection factories and topics/queues. This is done from "Resources -> JMS -> Connection Factories", "Resources -> JMS -> Topic Connection Factories", "Resources -> JMS -> Queue Connection Factories" and "Resources -> JMS -> Queues", "Resources -> JMS -> Topics".
For our setup we created a Topic Connection Factory with the following properties (select ActiveMQ as the provider as the first step):
and a Topic withe the following properties:
- Name: Topic Connection Factory
- JNDI name: TopicConnectionFactory
- External JNDI name: TopicConnectionFactory
One other tool you might find useful is the WAS dumpNameSpace utility which can be found in <WAS_PROFILE>/bin - as you'd expect it dumps out the JNDI namespace so you can see if eveything looks right. For more information on this, see the Information Center.
- Name: System Message Topic
- JNDI name: jms/systemMessageTopic
- External JNDI name: