11 Replies Latest reply on Jul 16, 2012 10:11 PM by jbertram

    Proper Reconnection Configuration

    mikkeljb

      Hi

       

      We are using the HornetQ server in JBoss Application Server 7.1.1

       

      We have  a problem when consumers need  to automatically reconnect to a server after a  reboot.

      Could somone please point out the error in the configuration?

       

      Thanks

      Mikkel

       

      We are using two Jboss servers (A, B)

      A and B are running the same standalone.xml configuration.

      A have the loopback ip and are therefore the hornetQ server.

      A and B are running the same ear file containing MDB's consuming from the hornetQ server.

       

      Both the machines are rebooted.

      B starts up before A

      B will try to connect to A  periodically until A is started, then it seems to get connected.

      But only the MDBs on A will be registred as consumers

       

      The following is from the standalone.xml used on both machines:

      [....]

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

                  <hornetq-server>

                      <persistence-enabled>true</persistence-enabled>

                      <jmx-management-enabled>true</jmx-management-enabled>

                      <message-counter-enabled>true</message-counter-enabled>

                      <message-counter-sample-period>60000</message-counter-sample-period>

                      <message-counter-max-day-history>7</message-counter-max-day-history>

                      <transaction-timeout>300000</transaction-timeout>

                      <id-cache-size>100000</id-cache-size>

                      <journal-file-size>102400</journal-file-size>

                      <journal-min-files>2</journal-min-files>

       

                      <connectors>

                          <netty-connector name="netty" socket-binding="messaging"/>

                          <netty-connector name="netty-throughput" socket-binding="messaging-throughput">

                              <param key="batch-delay" value="50"/>

                          </netty-connector>

                          <in-vm-connector name="in-vm" server-id="0"/>

                      </connectors>

       

                      <acceptors>

                          <netty-acceptor name="netty" socket-binding="messaging"/>

                          <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">

                              <param key="batch-delay" value="50"/>

                              <param key="direct-deliver" value="false"/>

                          </netty-acceptor>

                          <in-vm-acceptor name="in-vm" server-id="0"/>

                      </acceptors>

       

                      <security-settings>

                          <security-setting match="#">

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

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

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

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

                          </security-setting>

                      </security-settings>

       

                      <address-settings>

                          <address-setting match="#">

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

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

                              <redelivery-delay>3000</redelivery-delay>

                              <max-delivery-attempts>3</max-delivery-attempts>

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

                          </address-setting>

                          <address-setting match="jms.queue.workerQueue">

                              <max-size-bytes>1073741824</max-size-bytes>

                              <address-full-policy>DROP</address-full-policy>

                          </address-setting>

                            <address-setting match="jms.queue.DLQ">

                              <max-size-bytes>1073741824</max-size-bytes>

                              <page-size-bytes>104857600</page-size-bytes>

                              <address-full-policy>PAGE</address-full-policy>

                          </address-setting>

                          <address-setting match="jms.queue.ExpiryQueue">

                              <max-size-bytes>1073741824</max-size-bytes>

                              <page-size-bytes>104857600</page-size-bytes>

                              <address-full-policy>PAGE</address-full-policy>

                          </address-setting>

                      </address-settings>

       

                      <jms-connection-factories>

                          <connection-factory name="InVmConnectionFactory">

                              <connectors>

                                  <connector-ref connector-name="in-vm"/>

                              </connectors>

                              <entries>

                                  <entry name="java:/ConnectionFactory"/>

                              </entries>

                              <consumer-window-size>0</consumer-window-size>

                          </connection-factory>

                          <connection-factory name="RemoteConnectionFactory">

                              <connectors>

                                  <connector-ref connector-name="netty"/>

                              </connectors>

                              <entries>

                                  <entry name="RemoteConnectionFactory"/>

                                  <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>

                              </entries>

                          </connection-factory>

                          <pooled-connection-factory name="hornetq-ra">

                              <transaction mode="xa"/>

                              <connectors>

                                  <connector-ref connector-name="netty"/>

                              </connectors>

                              <entries>

                                  <entry name="java:/JmsXA"/>

                              </entries>

                              <retry-interval>1000</retry-interval>

                              <retry-interval-multiplier>1.5</retry-interval-multiplier>

                              <max-retry-interval>30000</max-retry-interval>

                              <reconnect-attempts>1000</reconnect-attempts>

                          </pooled-connection-factory>

                      </jms-connection-factories>

       

                      <jms-destinations>

                          <jms-queue name="workerQueue">

                              <entry name="queue/workerQueue"/>

                              <entry name="java:jboss/exported/jms/queue/workerQueue"/>

                          </jms-queue>

                          </jms-queue>

                          <jms-queue name="DLQ">

                              <entry name="queue/DLQ"/>

                              <entry name="java:jboss/exported/jms/queue/DLQ"/>

                          </jms-queue>

                          <jms-queue name="ExpiryQueue">

                              <entry name="queue/ExpiryQueue"/>

                              <entry name="java:jboss/exported/jms/queue/ExpiryQueue"/>

                          </jms-queue>

                      </jms-destinations>

                  </hornetq-server>

              </subsystem>

      <interfaces>

      […]

              <interface name="remotehornetq">

                  <loopback-address value="192.168.1.9"/>

              </interface>

          </interfaces>

        • 1. Re: Proper Reconnection Configuration
          jbertram

          I recommend you read the relevant documentation.

          • 2. Re: Proper Reconnection Configuration
            mikkeljb

            Thank you for the link.

             

            But I am not able to see why the MDB's on machine B are not registered, after a restart.

             

            If the machines are started in the same order, after they both have been cleaned for data and tmp files, before starting. Machine B will (re)connect properly, and the the MDB's on machine B are correctly registred as consumers on HornetQ server running on machine A.

             

            So this is only a reconnection issue.

             

            If somebody could please point out, where I am going wrong I would be grateful.

            • 3. Re: Proper Reconnection Configuration
              jbertram

              What activation configuration properties are you using for the MDB?

              • 4. Re: Proper Reconnection Configuration
                mikkeljb

                We use the follow configuration propeties for our MDB's

                 

                @MessageDriven(

                        activationConfig = {

                                @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

                                @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/exported/jms/queue/workerQueue"),

                                @ActivationConfigProperty(propertyName = "maxSession", propertyValue ="8")

                        }

                )

                • 5. Re: Proper Reconnection Configuration
                  jbertram

                  Are there any exceptions or WARN messages in your log which indicate the MDB is trying to reconnect?

                  • 6. Re: Proper Reconnection Configuration
                    mikkeljb

                    Thank you  very much for the guiding comments.

                     

                    I have by now found the solution. In case anyone makes the same mistake, the problem was that, I haven’t set the configuration property on the MDB’s:

                    @ActivationConfigProperty(propertyName = "setupAttempts", propertyValue = "-1"),

                     

                    That meat the default value (10) was used, so after 20 seconds the MDB’s stopped their attempts to get registered as consumers. Even though the hornetQ client mange to reconnect to the server later on.

                     

                    The other problem was, that in my test to see if the problem occurred on ‘Clean’ servers. I started the HornetQ server too quickly.

                    • 7. Re: Proper Reconnection Configuration
                      rsinghal

                      I am facing same problem. My topics and queues are deployed on remote hornetQ server embedded in JBoss AS 7.2.0Alpha1 and MDBs are deployed on other JBoss As 7.2.0Alpha1 server. I configured property mentioned by you for MDB configuration in jboss-ejb3.xml. It doesn't seem to honour it.

                      • 8. Re: Proper Reconnection Configuration
                        jbertram

                        You should only need to add it to ejb-jar.xml as an activation configuration property.  Where are you adding it in jboss-ejb3.xml?

                        • 9. Re: Proper Reconnection Configuration
                          rsinghal

                          I'll try what you have suggested. I added setupAttempts in following way:

                           

                          <jee:message-driven>

                                    <jee:ejb-name>MyMDB</jee:ejb-name>

                                    <jee:activation-config>

                                      <jee:activation-config-property>

                                                   <jee:activation-config-property-name>destination</jee:activation-config-property-name>

                                                 <jee:activation-config-property-value>my.test.topic</jee:activation-config-property-value>

                                      </jee:activation-config-property>

                                      <jee:activation-config-property>

                                                   <jee:activation-config-property-name>connectorClassName</jee:activation-config-property-name>

                                                   <jee:activation-config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</jee:activation-config-property-value>

                                      </jee:activation-config-property>

                                      <jee:activation-config-property>

                                                   <jee:activation-config-property-name>connectionParameters</jee:activation-config-property-name>

                                                   <jee:activation-config-property-value>host=hostName;port=5445</jee:activation-config-property-value>

                                      </jee:activation-config-property>

                                      <jee:activation-config-property>

                                                   <jee:activation-config-property-name>setupAttempts</jee:activation-config-property-name>

                                                   <jee:activation-config-property-value>-1</jee:activation-config-property-value>

                                      </jee:activation-config-property>                               

                                     </jee:activation-config>                               

                          </jee:message-driven>

                          • 10. Re: Proper Reconnection Configuration
                            rsinghal

                            It did not work even after adding it to ejb-jar.xml. Am I missing something?

                            • 11. Re: Proper Reconnection Configuration
                              jbertram

                              My guess is that you're adding the activation configuration property properly, but that you're problem just isn't the same as the original author.  Perhaps you should start a new thread and fully explain the issue you're facing.