9 Replies Latest reply: Mar 25, 2011 6:59 AM by Claudio D'Angelo RSS

Clustered HornetQ and ra.xml

Claudio D'Angelo Newbie

Hi,

I've two server HornetQ standalone with two master/slave in cluster:

Live1 -- Backup1 \

                                  > Live1 e Live2 in cluster

Live2 -- Backup2 /

 

I've a Jboss 4.2.2 with a server instance with external hornetq configuration. How must I configure the ra.xml in the deploy/jms-ra.rar/META-INF to use the two hornetq server Live1 and Live2 with the backups server Backup1 and Backup2?

  • 1. Clustered HornetQ and ra.xml
    Andy Taylor Master

    have a look at the jca remote example

  • 2. Clustered HornetQ and ra.xml
    Claudio D'Angelo Newbie

    Yes...

    Connection to a remote hornetq work fine but I want connect to a server list.

    In hornetq-jms.xml under deploy/hornetq.sar of jboss you can configure:

     

    <connection-factory name="NettyConnectionFactory">

          <connectors>

             <connector-ref connector-name="cl-1"/>

             <connector-ref connector-name="cl-2"/>

          </connectors>

          <entries>

             <entry name="/ConnectionFactory"/>

             <entry name="/XAConnectionFactory"/>

          </entries>

       </connection-factory>

     

    but in the ra.xml I don't find any example to configure with more server

  • 3. Clustered HornetQ and ra.xml
    Andy Taylor Master

    i dont think thats supported in the current version, altho it is in the next which should be released this week

  • 4. Clustered HornetQ and ra.xml
    jeroen.v Newbie

    In 2.1.2 you have to use multicasting if you want to connect to a cluster from JCA.

    Only other option available for the JCA is to connect to a single node.

  • 5. Clustered HornetQ and ra.xml
    Claudio D'Angelo Newbie

    Yes, I tried the multicast and work fine but the performance was bad. A testcase using only a server hornetq employed 11 sec. while with 2 hornetq server in multicast employed 5 min.

    Probably the broadcast in the connection catch more time.

  • 6. Clustered HornetQ and ra.xml
    Andy Taylor Master

    that doesnt seem right, what kind of test was it, multicast is only used for initial discovery so should be no slower, unless your creating a new connection every time

  • 7. Clustered HornetQ and ra.xml
    Claudio D'Angelo Newbie

    The product is a "proxy" for intercommunication. It has formed by webservices and MDB.

    When start a request there are many producers (web services) and consumers (MDB). When the ws must produce a message use the ConnectionFactory of the JNDI to create the connection/session and resolve the queue.

     

    To test the multicast without the product (that it is more complex) I've write a simple MDB that write out the message and a simple class like producer. The producer resolve the Queue and the ConnectionFactory using the jndi of the jboss server where is present the MDB.

    Using the direct connection the time of the connection ConnectionFactory.createConnection() end in 5 ms (circa) while using multicast the time grow to 300/400 ms.

    I use an hornetq server in my machine, another one in a VMWare in my machine and a server jboss in another VMWare in my machine.

    (I've proposed to execute test in a real environment)

     

    The product must create a new connection every time otherwise how can update servers status? Doesn't it?

     

    The multicast work fine but I must try the cluster without UDP and I don't be able to validate this configuration with hornetq.

  • 8. Clustered HornetQ and ra.xml
    Andy Taylor Master

    Im guessing you arent using the correct connection factory ("JmsXA") which pools its connections.

  • 9. Clustered HornetQ and ra.xml
    Claudio D'Angelo Newbie

    Below my jboss configurations whats wrong?

     

    The hornetq.sar/jms-ds.xml

     

    --------------

    <connection-factories>

       <!--

        JMS Stuff

       -->

     

       <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="hornetq:service=JMSProviderLoader,name=JMSProvider">

          <attribute name="ProviderName">DefaultJMSProvider</attribute>

          <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>

          <attribute name="FactoryRef">java:/XAConnectionFactory</attribute>

          <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>

          <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>

       </mbean>

       <!--

        JMS XA Resource adapter, use this to get transacted JMS in beans

       -->

       <tx-connection-factory>

          <jndi-name>JmsXA</jndi-name>

          <xa-transaction/>

          <rar-name>jms-ra.rar</rar-name>

          <connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>

          <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>

          <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>

          <max-pool-size>20</max-pool-size>

          <security-domain-and-application>JmsXARealm</security-domain-and-application>

       </tx-connection-factory>

    </connection-factories>

    ----------------

     

    The hornetq.sar/hornetq-jms.xml

     

    ----------------

    <configuration xmlns="urn:hornetq"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">

     

       <connection-factory name="NettyConnectionFactory">

          <discovery-group-ref discovery-group-name="dg-group1" />

          <entries>

             <entry name="/ConnectionFactory"/>

             <entry name="/XAConnectionFactory"/>

          </entries>

       </connection-factory>

     

         <connection-factory name="NettyThroughputConnectionFactory">

          <discovery-group-ref discovery-group-name="dg-group1" />

            <entries>

                <entry name="/ThroughputConnectionFactory"/>

                <entry name="/XAThroughputConnectionFactory"/>

            </entries>

        </connection-factory>

     

       <queue name="DLQ">

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

       </queue>

     

       <queue name="ExpiryQueue">

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

       </queue>

    ....

    -----------------

     

     

    the hornetq-sar/hornetq-configuration.xml

    -----------------

    <configuration xmlns="urn:hornetq"

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">

     

       <log-delegate-factory-class-name>org.hornetq.integration.logging.Log4jLogDelegateFactory</log-delegate-factory-class-name>

      

       <bindings-directory>${jboss.server.data.dir}/hornetq/bindings</bindings-directory>

     

       <journal-directory>${jboss.server.data.dir}/hornetq/journal</journal-directory>

      

       <journal-min-files>10</journal-min-files>

      

       <large-messages-directory>${jboss.server.data.dir}/hornetq/largemessages</large-messages-directory>

     

       <paging-directory>${jboss.server.data.dir}/hornetq/paging</paging-directory>

     

       <discovery-groups>

          <discovery-group name="dg-group1">

             <group-address>239.255.100.100</group-address>

             <group-port>9876</group-port>

             <refresh-timeout>10000</refresh-timeout>

          </discovery-group>

       </discovery-groups>

      

       <cluster-connections>

          <cluster-connection name="my-cluster">

             <address>jms</address>    

              <discovery-group-ref discovery-group-name="dg-group1"/>

          </cluster-connection>

       </cluster-connections>

     

       <security-settings>

          <security-setting match="#">

             <permission type="createNonDurableQueue" roles="guest"/>

             <permission type="deleteNonDurableQueue" roles="guest"/>

             <permission type="consume" roles="guest"/>

             <permission type="send" roles="guest"/>

          </security-setting>

       </security-settings>

     

       <address-settings>

          <!--default for catch all-->

          <address-setting match="#">

             <dead-letter-address>jms.queue.DLQ</dead-letter-address>

             <expiry-address>jms.queue.ExpiryQueue</expiry-address>

             <redelivery-delay>0</redelivery-delay>

             <max-size-bytes>10485760</max-size-bytes>      

             <message-counter-history-day-limit>10</message-counter-history-day-limit>

             <address-full-policy>BLOCK</address-full-policy>

          </address-setting>

       </address-settings>

     

    </configuration>

    --------------------

     

    the jms-ra.rar/META-INF/ra.xml

     

    -------------------

    <connector xmlns="http://java.sun.com/xml/ns/j2ee"

               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

               http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"

               version="1.5">

     

       <description>HornetQ 2.0 Resource Adapter</description>

       <display-name>HornetQ 2.0 Resource Adapter</display-name>

     

       <vendor-name>Red Hat Middleware LLC</vendor-name>

       <eis-type>JMS 1.1 Server</eis-type>

       <resourceadapter-version>1.0</resourceadapter-version>

     

       <resourceadapter>

          <resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>

          <config-property>

            <description>The discovery address</description>

            <config-property-name>DiscoveryAddress</config-property-name>

            <config-property-type>java.lang.String</config-property-type>

            <config-property-value>239.255.100.100</config-property-value>

          </config-property>

          <config-property>

            <description>The discovery port</description>

            <config-property-name>DiscoveryPort</config-property-name>

            <config-property-type>java.lang.Integer</config-property-type>

            <config-property-value>9876</config-property-value>

          </config-property>

     

          <outbound-resourceadapter>

             <connection-definition>

                <managedconnectionfactory-class>org.hornetq.ra.HornetQRAManagedConnectionFactory</managedconnectionfactory-class>

     

                <config-property>

                   <description>The default session type</description>

                   <config-property-name>SessionDefaultType</config-property-name>

                   <config-property-type>java.lang.String</config-property-type>

                   <config-property-value>javax.jms.Queue</config-property-value>

                </config-property>

                <config-property>

                   <description>Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality</description>

                   <config-property-name>UseTryLock</config-property-name>

                   <config-property-type>java.lang.Integer</config-property-type>

                   <config-property-value>0</config-property-value>

                </config-property>

     

                <connectionfactory-interface>org.hornetq.ra.HornetQRAConnectionFactory</connectionfactory-interface>

                <connectionfactory-impl-class>org.hornetq.ra.HornetQRAConnectionFactoryImpl</connectionfactory-impl-class>

                <connection-interface>javax.jms.Session</connection-interface>

                <connection-impl-class>org.hornetq.ra.HornetQRASession</connection-impl-class>

             </connection-definition>

             <transaction-support>XATransaction</transaction-support>

             <authentication-mechanism>

                <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>

                <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>

             </authentication-mechanism>

             <reauthentication-support>false</reauthentication-support>

          </outbound-resourceadapter>

     

          <inbound-resourceadapter>

             <messageadapter>

                <messagelistener>

                   <messagelistener-type>javax.jms.MessageListener</messagelistener-type>

                   <activationspec>

                      <activationspec-class>org.hornetq.ra.inflow.HornetQActivationSpec</activationspec-class>

                      <required-config-property>

                          <config-property-name>destination</config-property-name>

                      </required-config-property>

                   </activationspec>

                </messagelistener>

             </messageadapter>

          </inbound-resourceadapter>

     

       </resourceadapter>

    </connector>

    -------------------