Integrating ActiveMQ 5.13.1 with WebSphere Application Server 8.5

I’ve spent the last several days trying to get ActiveMQ integrated with WebSphere AS 8.5 to have a local environment available for testing some JMS code. It was pretty difficult to find recent information out there so I thought I’d share how I was able to get something to work.

I was able to cobble together directions I found on various sites but as always those sites left out bits of information that I found very handy to know so here I’ll try to do a step by step example. Please let me know if I missed something because I know how aggravating that can be.


ActiveMQ

I set up ActiveMQ with the default settings, the most important being the port it listens on which is 61616. If you use a different port just make sure to use that port number in this example.

Step 1: Add a queue in ActiveMQ

This isn’t strictly required. The default behavior with ActiveMQ is to create queues dynamically if the queue named in the call isn’t found. For this example though add a queue named “testqueue” as this will be the name used in the rest of the example.

Set up 'testqueue' in ActiveMQ
Set up “testqueue” in ActiveMQ

WebSphere

Step 2: Configure WebSphere – The JMS Provider

The first step in WebSphere is to create a JMS Provider for ActiveMQ. This is done via the WebSphere administrator console under the Resources menu on the left side of the page.

  1. Expand Resources
  2. Expand JMS
  3. Click on JMS Providers

Note: I tried to get this to work by specifying the ActiveMQ libraries in the Class path box but that didn’t seem to work for me. I ended up putting the libraries in <WAS_ROOT>/lib/ext. The list of libraries for this version of ActiveMQ is:

  1. activemq-client-5.13.1.jar
  2. hawtbuf-1.11.jar
  3. slf4j-api-1.7.13.jar

You may want to try specifying these (with the full path) in Class path and see if it works for you.

Note: I tried to get this to work by specifying the ActiveMQ libraries in the Class path box but that didn’t seem to work for me. I ended up putting the libraries in WAS_ROOT/lib/ext. The list of libraries for this version of ActiveMQ is:

1. activemq-client-5.13.1.jar
2. hawtbuf-1.11.jar
3. slf4j-api-1.7.13.jar

You may want to try specifying these (with the full path) in Class path and see if it works for you.

Set up the rest of the fields per the screenshot below. I used org.apache.activemq.jndi.ActiveMQWASInitialContextFactory because the older examples I found when putting this how-to together used it. I did find one example that used the regular ActiveMQInitialContextFactory but I haven’t tried it. The difference in the classes is how custom properties (set up below) are passed to the factory.

JMS Provider configuration
JMS Provider Information

The next thing that needs to be done is set up some custom properties for the provider. This needs to be done because the ActiveMQ context factory normally does this thru a properties file that is read at startup (jndi.properites as seen here). As noted in that document every connection factory and queue/topic needs to be listed here.

Note the naming of the queue entry. It follows the JNDI name using periods instead of slashes. If my queue name were jms/testqueue the property would be called java.naming.queue.jms.testqueue.

Also, if you’re using a topic instead of a queue use java.naming.topic instead.

JMS Provider Custom Properties
JMS Provider Custom Properties

Step 3: Configure WebSphere – The Queue Connection Factory

The next step is to set up the Queue Connection Factory. This is also done via the WebSphere administrator console under the Resources menu on the left side of the page.

  1. Expand Resources
  2. Expand JMS
  3. Click on Queue connection factories
Queue Connection Factory configuration
Queue Connection Factory configuration

Step 4: Configure WebSphere – Set up the Queue

The next step is to set up the Queue. This is also done via the WebSphere administrator console under the Resources menu on the left side of the page.

  1. Expand Resources
  2. Expand JMS
  3. Click on Queues

The most important thing to note here is that External JNDI Name must match the value of the queue you provided in the custom properties of the provider in Step 2.

Queue configuration
Queue configuration

Java

Step 5: The Java code

Here is some sample Java code using Spring that shows how to hook up a JmsTemplate and use it to send a simple test message.

<jee:jndi-lookupid="jmsConnectionFactory"jndi-name="jms/QCF"/>

<beanid="jmsTemplate"class="org.springframework.jms.core.JmsTemplate">
<propertyname="connectionFactory">
<refbean="jmsConnectionFactory"/>
</property>
<propertyname="destinationResolver">
<refbean="jmsDestResolver"/>
</property>
</bean>

<beanid="jmsDestResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver"/>

Here the most important point to note is that the JNDI name for the queue is used here when sending the message via the JmsTemplate, it is not the name of the queue as set up in ActiveMQ.

jmsTemplate.send("jms/testqueue",newMessageCreator(){
    publicMessagecreateMessage(Sessionsession)throwsJMSException{
        return session.createTextMessage("helloqueueworld");
    }
});

Conclusion

I hope you find this useful. I wanted to provide a full queue to code example which is something I wasn’t able to find when trying to set this up myself.

Resources

5 thoughts on “Integrating ActiveMQ 5.13.1 with WebSphere Application Server 8.5

  1. It seems that the linked pictures which are originated on google drive are no longer available. As you state at the beginning it’s a little bit tricky to figure out the missing parts…

    Like

    1. Hi Richard yeah you’re right. I will re link the image files. They had to be moved and apparently I missed some posts. Did you figure it out or do you need these updated right away?

      Like

      1. Thank you very much for restoring the pictures. Finally I figured it out and was able to send and receive messages. Finally one thing left is the security setting to allow receiving object messages. Thinking of patching the AMQ source code and set it initially of true. (Don’t blame me 🙂 for a test enviroment still better than wasting a couple of days finding the right spot… Once again thank you very much…

        Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: