7 Replies Latest reply on Mar 26, 2014 5:57 AM by Tuan Pham

    JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ

    matvei Newbie

      I've tried to find an example of JMS Bridge, consuming messages from Websphere MQ Queue to HornetQ Queue, but it seems like the documentation refers to older Jboss versions with mbeans config.


      Anyone has an example of a JMS Bridge (NOT core bridge) for Jboss 7 with HornetQ 2.3?


      I found following (old) references:




        • 1. Re: JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ
          Miroslav Novak Master



          there is example config for JMS bridge which is working in AS 7.2/EAP 6.1:


          <subsystem xmlns="urn:jboss:domain:messaging:1.3">





                       <jms-bridge name="myBridge">


                              <connection-factory name="jms/RemoteConnectionFactory"/>

                              <destination name="jms/queue/InQueue"/>



                              <connection-factory name="jms/RemoteConnectionFactory"/>

                              <destination name="jms/queue/OutQueue"/>


                                  <property key="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>

                                  <property key="java.naming.provider.url" value="remote://"/>













          This creates JMS bridge between two AS 7.2 servers. I did not try with Websphere MQ  but following is what I guess is needed to configure:


          1. Set correct  properties in <context>, something like:


                                  <property key="java.naming.factory.initial" value="com.ibm.mq.jms.context.WMQInitialContextFactory"/>

                                  <property key="java.naming.provider.url" value="ip_of_websheremq_server:1414/CH"/>

                                  <property key="java.naming.factory.url.pkgs" value="com.ibm.mq.jms.naming"/>



          2. Now AS 7.2 has no idea where to find class WMQInitialContextFactory or com.ibm.mq.jms.naming so it's necessary to add new module with correct jars:

          • Create new directory $JBOSS_HOME/modules/system/layers/base/ibm/wsmq/main
          • Create file module.xml in$JBOSS_HOME/modules/system/layers/base/ibm/wsmq/main directory which links all the jar files (not sure if all of the jars are needed):

          <?xml version="1.0" encoding="UTF-8"?>

          <module xmlns="urn:jboss:module:1.1" name="ibm.wsmq">

                  <resource-root path="remote-object-factory-ibmmq-1.0.jar"/>  <!-- jar file with the created object factory -->
                  <resource-root path="mqcontext.jar"/>
                  <resource-root path="dhbcore.jar"/>
                  <resource-root path="com.ibm.mqjms.jar"/>
                  <resource-root path="com.ibm.mq.pcf.jar"/>
                  <resource-root path="com.ibm.mq.jmqi.jar"/>
                  <resource-root path="com.ibm.mq.jar"/>
                  <resource-root path="com.ibm.mq.headers.jar"/>
                  <resource-root path="com.ibm.mq.commonservices.jar"/>

                  <module name="javax.api"/>
                  <module name="javax.resource.api"/>
                  <module name="javax.validation.api"/>
                  <module name="org.hibernate.validator"/>
                  <module name="org.jboss.as.naming"/>
                  <module name="org.jboss.as.transactions"/>
                  <module name="org.jboss.common-core"/>
                  <module name="org.jboss.jboss-transaction-spi"/>
                  <module name="org.jboss.ironjacamar.api"/>
                  <module name="org.jboss.logging"/>
                  <module name="org.jboss.threads"/>
                  <module name="javax.xml.stream.api"/>
                  <module name="javax.jms.api" />

          • Copy all jars from <resources> to $JBOSS_HOME/modules/system/layers/base/ibm/wsmq/main


          If it's still not working try to edit $JBOSS_HOME/modules/system/layers/base/org/jboss/as/messaging/main/module.xml and add into <dependencies>:

          <module name="ibm.wsmq"/>


          Hopefully this gets you further.




          • 2. Re: JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ
            matvei Newbie

            Thanks, I'll try these classes, but at the moment I use Websphere JCA ResourceAdapter, have no idea how integrate it inside "source/context" of JMS Bridge. The config for this rar looks like:





            <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
                                    <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/IVTCF" enabled="true" use-java-context="true" pool-name="connection-definition" use-ccm="true">
                                        <config-property name="port">
                                        <config-property name="hostName">
                                        <config-property name="channel">
                                        <config-property name="transportType">
                                        <config-property name="queueManager">
                                    <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/Updates" enabled="true" use-java-context="true" pool-name="Updates">
                                        <config-property name="baseQueueName">



            And aftewards I may use this "Updates" queue for my MDB:



            @MessageDriven( name="UpdateCheck",
                    activationConfig = 
                        @ActivationConfigProperty(propertyName = "messagingType",propertyValue="javax.jms.MessageListener"),
                        @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/Updates"),
                        @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"),
                        @ActivationConfigProperty(propertyName = "maxMessages", propertyValue = "1"),            
                        @ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.SVRCONN"),
                        @ActivationConfigProperty(propertyName = "hostName", propertyValue = "mqserver"),
                        @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QM01"),
                        @ActivationConfigProperty(propertyName = "port", propertyValue = "1421"),
                        @ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT")
              public class Updates 
                extends BasicMDB 
                implements MessageListener { ..}
            • 3. Re: JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ
              Justin Bertram Master

              If you have an MDB which can consume from WebSphereMQ and an outbound connection factory which can send to WebSphereMQ then why do you need/want the JMS bridge?


              In any case, the JMS bridge doesn't use a JCA RA so none of your current configuration really applies to it.  The JMS bridge connects to a provider just like a standalone remote client would.  In other words it uses JNDI to look up the connection factory and destination and then uses the JMS API to send/receive messages.  Of course, every vendor implements JNDI differently so each needs unique InitialContext parameters.  That is what the <context> for the <source> and <target> are for on the bridge.  The entries here would be the same kind of entries used from a remote standalone JMS client.

              • 4. Re: JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ
                matvei Newbie

                I just want to detouch the application from MQ configuration. If I use ejb3 deployment descriptor -  I can use jboss system properties to inject there config parameters, but the problem is, that I want to use Camel XML Spring config to send messages to different destinations and than inject this bean into Session Bean or MDB. In such a case I can simpy call the method "sendMessageToTheSecondQueue(Message m)" or "sendMessageToTheThirdQueue(Message m)". Camel takes the delivery liability and I can route/change the messages if necessary. Spring searches for the file "businesBeans.xml" and I can not inject there (at least in Jboss 7.2) any system properties, that means that I have to hardcode connection parameters inside EAR archive and that's absolute "no go" for the packaging system we use...


                Thanks for the hint abour Bridge approach. I will try to use standard classes, hope that will work.

                • 5. Re: JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ
                  Tuan Pham Newbie

                  Hi Matteo Ts,

                  I also have a task to make hornetq work with MQ then, I would like to now that using Bridge approach is correct way ?. and do you have any specific code example can share.

                  Thank you in advanced

                  • 6. Re: JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ
                    Justin Bertram Master

                    Both the JMS bridge and the WebSphereMQ JCA Resource Adapter can be used to integrate.  Neither is necessarily "correct."  It really depends on your use-case.

                    • 7. Re: JBOSS 7 JMS Bridge, connect HornetQ to Webpsphere MQ
                      Tuan Pham Newbie

                      Thank Justin Bertram for the answers, I will investigate more my case and maybe ask in detail.