Tags

, , , , ,

I was working on a solution based on ActiveMQ where we required to pull messages from GlassFishMQ (based on OpenMQ) and put them on OracleAQ.

Now, ActiveMQ uses Camel ESB for internal message routing, this proved useful. However try as I might, I couldn’t find a simple solution to what I wanted to achieve.

My target was to configure ActiveMQ broker which’ll act as a message router and decouple the 2 systems. Both would be unaware of its presence. Sounds really good in theory providing loose coupling.

But the difficult part was finding documentation. All the documentation available was about using ActiveMQ as JMS provider in GlassFish. Not what I was looking at.

So finally after much difficulty, I found the solution. It is simple but difficult to find.

Step 1) Copy imq.jar to ActiveMQ lib directory. The jar is found in GLASSFISH_HOME/imq/lib

Step 2) Add below lines to your activemq configuration file –

This line creates a default connectionFactory using host localhost and port 7676

<bean id="connectionFactoryOpenMQQueue"/>

 

This part creates a bean with credentials

<bean id="openMQQueueCredentials">
<property name="targetConnectionFactory">
<ref bean="connectionFactoryOpenMQQueue"/>
</property>
<property name="username">
<value>admin</value>
</property>
<property name="password">
<value>admin</value>
</property>
</bean>

This part created the actual scheme, namespace identifier for the connection.

<bean id="openMQQueue">
<property name="connectionFactory" ref="openMQQueueCredentials"/>
</bean>

Step 3) Add the routing instructions

This’ll consume message from GlassFishMQ and put it on ActiveMQ’s queue. You can check the messages at http://localhost:8161/admin

<route>
<from uri="openMQQueue:queue:q_user_info" />
<to  uri="activemq:queue:amq.temp.userinfo.queue"/>
</route>

Referred to this info on how to configure the ConnectionFactory – http://docs.sun.com/source/817-0355/adminobj.html

Advertisement