Setting up a JMS bridge between Weblogic and HornetQPosted: 09/19/2011
I’d like to publish my notes about how to setup a basic JMS bridge between a Weblogic Server and an instance of HornetQ, running on a JBoss 6.1 Application Server. My reference was the document “Configuring and Managing the WebLogic Messaging Bridge”.
First of all, I copied the following libraries to a folder residing in a filesystem of my Weblogic server:
Later on, I set the PRE_CLASSPATH variable pointing it to these libraries into the script setDomainEnv and started Weblogic, so I could use the console to create the source bridge destination, a typical Weblogic one, just selecting the default JNDI adapter name: eis.jms.WLSConnectionFactoryJNDIXA, and putting the JNDI name of my Connection Factory and my Queue in. Here you have an excerpt of the resulting config.xml file:
<jms-bridge-destination> <name>JMS Bridge Destination-Source</name> <adapter-jndi-name>eis.jms.WLSConnectionFactoryJNDIXA</adapter-jndi-name> <classpath></classpath> <connection-factory-jndi-name>jms/TestXAQueueConnectionFactory</connection-factory-jndi-name> <connection-url></connection-url> <destination-jndi-name>jms/TestQueue</destination-jndi-name> </jms-bridge-destination>
After that, I created the target bridge destination, the HornetQ one (I’ve previously set up the needed objects on HornetQ, please review its user manual for further information). In addition to the JNDI names of the Connection Factory and the Queue, I had to configure the URL of the JNDI server used by the HornetQ instance, in my case jnp://srvhornetq.test.local:1099. After save the destination, I had to edit it, modify the default initial connection factory weblogic.jndi.WLInitialContextFactory to org.jnp.interfaces.NamingContextFactory, and restart the Weblogic server. The resulting piece of configuration on config.xml is:
<jms-bridge-destination> <name>JMS Bridge Destination-Target</name> <adapter-jndi-name>eis.jms.WLSConnectionFactoryJNDIXA</adapter-jndi-name> <classpath></classpath> <connection-factory-jndi-name>jms/TestXAQueueConnectionFactory</connection-factory-jndi-name> <initial-context-factory>org.jnp.interfaces.NamingContextFactory</initial-context-factory> <connection-url>jnp://srvhornetq.test.local:1099</connection-url> <destination-jndi-name>jms/TestQueue</destination-jndi-name> <destination-type>Queue</destination-type> </jms-bridge-destination>
Finally, I setup the bridge as usual, just selecting the source and target destinations, the quality of service, etc:
<messaging-bridge> <name>Test-Bridge</name> <target>DefaultServer</target> <source-destination>JMS Bridge Destination- Source</source-destination> <target-destination>JMS Bridge Destination-Target</target-destination> <selector></selector> <quality-of-service>Exactly-once</quality-of-service> <started>true</started> </messaging-bridge>
Please, be careful selecting the proper parameters for each situation, in order to avoid errors like JMS-107. For example, I recommend to create a javax.jms.XATopicConnectionFactory connection factory for a topic and a javax.jms.XAQueueConnectionFactory connection factory for a queue, but I don’t use a generic javax.jms.XAConnectionFactory Of course, the’re a lot of issues about security, transactions, etc, but that’s the topic for another post!