1 Reply Latest reply: Apr 18, 2012 7:14 AM by anil Konduru RSS

HornetQ Bridge setup

anil Konduru Newbie

Hi,

 

I am just trying to setup a bridge using HornetQ on JBoss 5.0.1 where my source and destination queues are on same server, i am doing this just to learn how to setup a JMS bridge. I am having issue while adding the bridge entry in hornet-configuration.xml org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'bridge'. below is the entry used. looks like filter element is not properly used, but JBoss doc says the same and somewhere it is given as     jms.queue.SSWATestInboundQueue    jms.queue.SSWATestOutboundQueue        org.hornetq.jms.example.HatColourChangeTransformer    1000    1.0    -1    false    true              any thoughts??

 

  • 1. Re: HornetQ Bridge setup
    anil Konduru Newbie

    I am able to setup the bridge as below. Hope this helps others.

     

     

    Jboss HornetQ JMS Bridge setup

     

    Prerequisites:

    1. Download HornetQ distribution hornetq-2.2.2.Final.zip

    2. Download Jboss Server 5.X

    3. Setup 2 Jboss instances, one as source and another one as target.

     

    HornetQ Bridge Setup:

     

    Adding HornetQ JMS Implementation to Jboss server:

    1. Extract hornetq-2.2.2.Final.zip into a separate directory, and set JBOSS_HOME as source Jboss server.

    Ex: set JBOSS_HOME=D:/Source_JBoss/Jboss_as

    1. Run buid.bat from hornetq-2.2.2.Final/config/jboss-as-5. This installs HornetQ onto source Jboss server.

    2. Set JBOSS_HOME as target Jboss server.

    Ex: set JBOSS_HOME=D:/Target_JBoss/Jboss_as

    1. Run buid.bat from hornetq-2.2.2.Final/config/jboss-as-5. This installs HornetQ onto target Jboss server.

    2. On both source and target servers, rename jboss-as\server\default folder as default-without-hornetq and jboss-as\server\default-with-hornetq as default.

     

    Creating source and target queues on source and target servers:

    1. Change default ports in jboss-as\server\default\conf\bindingservice.beans\META-INF\bindings-jboss-beans on target servers as source is already using the same ports. Attaching the file for reference.

     

    1. Set <property name="allowClientLogin">false</property> as true on target server in file jboss-eap-5.1\jboss-as\server\default\deploy\hornetq.sar. This is to allow test client send messages with given credentials.

    2. On both source and target servers, change guest=guest as admin=admin and uncomment the line in below files. This is to enabling the JMX console access with admin/admin and allowing client/application to send messages as admin/admin.

    Jmx-console-users

    messaging-roles

    messaging-users

    hornetq-users

    hornetq-roles

    1. Create source queue on source Jboss server, add below entry in D:/Source_JBoss\jboss-as\server\default\deploy\hornetq.sar\hornetq-jms

     

    <queue name="source">

    <entry name="/queue/source"/>

    </queue>

    1. Create target queue on target Jboss server, add below entry in D:/target_JBoss\jboss-as\server\default\deploy\hornetq.sar\hornetq-jms

     

    <queue name="target">

    <entry name="/queue/target"/>

    </queue>

     

    Setting up JMS Bridge on target which consumes message from source server when message available on source queue.

     

    1. Modify jboss-as\server\default\deploy\hornetq.sar\hornetq-jboss-beans on target server to add bridge. Please refer to the attached file for the configuration.

     

      <!-- The JMS Bridge -->
       <bean name="JMSBridge" class="org.hornetq.jms.bridge.impl.JMSBridgeImpl">
               <constructor>
                   <!-- Source ConnectionFactory Factory -->
                   <parameter>
                       <inject bean="SourceCFF"/>
                   </parameter>
                   <!-- Target ConnectionFactory Factory -->
                   <parameter>
                       <inject bean="TargetCFF"/>
                   </parameter>
                   <!-- Source DestinationFactory -->
                   <parameter>
                       <inject bean="SourceDestinationFactory"/>
                   </parameter>
                   <!-- Target DestinationFactory -->
                   <parameter>
                       <inject bean="TargetDestinationFactory"/>
                   </parameter>
                   <!-- Source username (no username here) -->
                   <parameter><null /></parameter>
                   <!-- Source password (no password here)-->
                   <parameter><null /></parameter>
                   <!-- Target username (no username here)-->
                   <parameter><null /></parameter>
                   <!-- Target password (no password here)-->
                   <parameter><null /></parameter>
                   <!-- Selector -->
                   <parameter><null /></parameter>
                   <!-- Interval to retry in case of failure (in ms) -->
                   <parameter>5000</parameter>
                   <!-- Maximum number of retries to connect to the source and target -->
                   <parameter>10</parameter>
                   <!-- Quality of service -->
                   <parameter>ONCE_AND_ONLY_ONCE</parameter>
                   <!-- Maximum batch size -->
                   <parameter>1</parameter>
                   <!-- Maximum batch time (-1 means infinite) -->
                   <parameter>-1</parameter>
                   <!-- Subscription name (no subscription name here)-->
                   <parameter><null /></parameter>
                   <!-- client ID  (no client ID here)-->
                   <parameter><null /></parameter>
                   <!-- concatenate JMS messageID to the target's message header -->
                   <parameter>true</parameter>
                   <!-- register the JMS Bridge in the JMX MBeanServer -->
                   <parameter>
                       <inject bean="MBeanServer"/>
                   </parameter>
                   <parameter>org.hornetq:service=JMSBridge</parameter>
               </constructor>
               <!--<property name="transactionManager">
                   <inject bean="TransactionManager"/>
               </property> -->
              
               <property name="transactionManager">
                   <inject bean="RealTransactionManager"/>
               </property>


               <!-- HornetQ JMS Server must be started before the bridge -->
               <depends>JMSServerManager</depends>
              
           </bean>

           <!--<bean name="TransactionManager" class="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple">
           </bean> -->

           <!-- SourceCFF describes the ConnectionFactory used to connect to the source destination -->
           <bean name="SourceCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">
               <constructor>
                   <parameter>
                       <inject bean="SourceJNDI" />
                   </parameter>
                   <parameter>/source/XAConnectionFactory</parameter>
               </constructor> 
           </bean>

           <!-- TargetCFF describes the ConnectionFactory used to connect to the target destination -->
           <bean name="TargetCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">
               <constructor>
                   <parameter>
                       <inject bean="TargetJNDI" />
                   </parameter>
                   <parameter>/target/XAConnectionFactory</parameter>
               </constructor> 
           </bean>

           <!-- SourceDestinationFactory describes the Destination used as the source -->
           <bean name="SourceDestinationFactory" class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">
               <constructor>
                   <parameter>
                       <inject bean="SourceJNDI" />
                   </parameter>
                   <parameter>/queue/source</parameter>
               </constructor> 
           </bean>

           <!-- TargetDestinationFactory describes the Destination used as the target -->
           <bean name="TargetDestinationFactory" class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">
               <constructor>
                   <parameter>
                       <inject bean="TargetJNDI" />
                   </parameter>
                   <parameter>/queue/target</parameter>
               </constructor> 
           </bean>
          
           <!-- JNDI is a Hashtable containing the JNDI properties required -->
           <!-- to connect to the *source* JMS resources                    -->      
          <bean name="SourceJNDI" class="java.util.Hashtable">
             <constructor class="java.util.Map">
                <map class="java.util.Hashtable" keyClass="java.lang.String"
                                                 valueClass="java.lang.String">
                   <entry>
                      <key>java.naming.factory.initial</key>
                      <value>org.jnp.interfaces.NamingContextFactory</value>
                   </entry>
                   <entry>
                      <key>java.naming.provider.url</key>
                      <!-- **************************************** -->
                      <!-- Replace with the *source* server address -->
                      <!-- **************************************** -->
                      <value>jnp://localhost:1099</value>
                   </entry>
                   <entry>
                      <key>java.naming.factory.url.pkgs</key>
                      <value>org.jboss.naming:org.jnp.interfaces"</value>
                   </entry>
                   <entry>
                      <key>jnp.timeout</key>
                      <value>5000</value>
                   </entry>
                   <entry>
                      <key>jnp.sotimeout</key>
                      <value>5000</value>
                   </entry>
                </map>
             </constructor>
          </bean>
         
          <!-- JNDI is a Hashtable containing the JNDI properties required -->
          <!-- to connect to the *target* JMS resources                    -->      
          <bean name="TargetJNDI" class="java.util.Hashtable">
             <constructor class="java.util.Map">
                <map class="java.util.Hashtable" keyClass="java.lang.String"
                                                 valueClass="java.lang.String">
                   <entry>
                      <key>java.naming.factory.initial</key>
                      <value>org.jnp.interfaces.NamingContextFactory</value>
                   </entry>
                   <entry>
                      <key>java.naming.provider.url</key>
                      <!-- **************************************** -->
                      <!-- Replace with the *target* server address -->
                      <!-- **************************************** -->
                      <value>jnp://localhost:1199</value>
                   </entry>
                   <entry>
                      <key>java.naming.factory.url.pkgs</key>
                      <value>org.jboss.naming:org.jnp.interfaces"</value>
                   </entry>
                   <entry>
                      <key>jnp.timeout</key>
                      <value>5000</value>
                   </entry>
                   <entry>
                      <key>jnp.sotimeout</key>
                      <value>5000</value>
                   </entry>
                </map>
             </constructor>
          </bean>

     

     

    Configuration added in above file explained below:

    a) <bean name="JMSBridge" class="org.hornetq.jms.bridge.impl.JMSBridgeImpl"> : This entry adds bridge to the target server.

    b) SourceCFF, TargetCFF, SourceDestinationFactory, TargetDestinationFactory: to specify source and destination servers' connection factories

    and queue details. Note: Default connection factories can be used without creating new.

    c) SourceJNDI, TargetJNDI: To Specify source and target servers details.

     

      1. create a client program to post message on source queue which is on source server.

        1. Start both source and target servers, post a message on source queue and verify the message count on source queue and target queue on server, both should have 1 message added. Queue can find under org.hornetq

      2.