1 Reply Latest reply on May 16, 2014 10:39 AM by hasmik.sarkezias

    hornetq client failover

    hasmik.sarkezias

      I am having a problem with hornetq client failover. I have gotten it to the point that the client says it successfully connected to the backup server, but in the logs I can see that it brings down the session. It seems like client loses the discovery information at that point because the next time it has to send a message it goes back to the intialConnectors which didn't have the backup server. What I don't know is whether the connection shouldn't have been closed or the using of initialConnectors is wrong?

       

      Any pointers will be appreicated.

      thanks,

      hasmik

       

      I am using spring's CachingConnectionFactory along with HornetQJmsConnectionFactory.

       

      <bean name="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" lazy-init="true">
         <property name="targetConnectionFactory" ref="hornetJmsConnectionFactory" />
         <property name="sessionCacheSize" value="2" />

          </bean>

       

        

       

          <bean name="hornetJmsConnectionFactory" class="org.hornetq.jms.client.HornetQJMSConnectionFactory"

         lazy-init="true">
         <constructor-arg value="true" /> <!-- HA -->
         <constructor-arg ref="listGeneratorJmsDiscoveryGroupConfiguration" />
         <property name="clientFailureCheckPeriod" value="30000" /> <!-- default --> 
          <property name="failoverOnInitialConnection" value="true" /> 
          <property name="initialConnectAttempts" value="15" /> 
                      <property name="reconnectAttempts" value="-1" /> 
                      <property name="retryInterval" value="5000" /> 
         

          </bean>

       

      Here is snippet of the log:

       

       

      8:55:58,873 DEBUG [org.hornetq.core.client] (Thread-1 (HornetQ-client-global-threads-1576972005)) Trying to connect with connector = org.hornetq.core.remoting.impl.netty.NettyConnectorFactory@701b9555, parameters = {port=5445, host=lxsjbshq01.xoominfo.com} connector = NettyConnector [host=lxsjbshq01.xoominfo.com, port=5445, httpEnabled=false, useServlet=false, servletPath=/messaging/HornetQServlet, sslEnabled=false, useNio=false]

      18:55:58,873 DEBUG [org.hornetq.core.client] (Thread-1 (HornetQ-client-global-threads-1576972005)) Started Netty Connector version 3.6.2.Final-c0d783c

      18:55:58,873 DEBUG [org.hornetq.core.client] (Thread-1 (HornetQ-client-global-threads-1576972005)) Trying to connect at the main server using connector :TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com

      18:55:58,873 DEBUG [org.hornetq.core.client] (Thread-1 (HornetQ-client-global-threads-1576972005)) Remote destination: lxsjbshq01.xoominfo.com/10.31.160.99:5445

      18:55:58,883 DEBUG [org.hornetq.core.client] (Thread-1 (HornetQ-client-global-threads-1576972005)) Reconnection successfull

      18:55:58,934 DEBUG [org.hornetq.core.client] (Thread-1 (HornetQ-client-global-threads-1576972005)) ClientSession couldn't be reattached, creating a new session

      18:55:58,960 DEBUG [org.hornetq.core.client] (Thread-1 (HornetQ-client-global-threads-1576972005)) ClientSession couldn't be reattached, creating a new session

      18:55:58,970 DEBUG [org.springframework.jms.connection.CachingConnectionFactory] (Thread-94) Closing cached Session: HornetQSession->DelegatingSession [session=ClientSessionImpl [name=7c60c56c-dc83-11e3-9bad-032410fa0b35, username=null, closed=false, factory = ClientSessionFactoryImpl [serverLocator=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com, TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com], discoveryGroupConfiguration=DiscoveryGroupConfiguration{name='dgroup', refreshTimeout=10000, discoveryInitialWaitTimeout=10000}], connectorConfig=TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com, backupConfig=TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq02-xoominfo-com], metaData=(jms-session=,)]@75d8ac9d]

      18:55:58,971 DEBUG [org.hornetq.core.client] (Thread-94) Calling close on session ClientSessionImpl [name=7c60c56c-dc83-11e3-9bad-032410fa0b35, username=null, closed=false, factory = ClientSessionFactoryImpl [serverLocator=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com, TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com], discoveryGroupConfiguration=DiscoveryGroupConfiguration{name='dgroup', refreshTimeout=10000, discoveryInitialWaitTimeout=10000}], connectorConfig=TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com, backupConfig=TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq02-xoominfo-com], metaData=(jms-session=,)]@75d8ac9d

       

       

      And here is when it's trying to use send a message again, it's trying to connect to the initalConnector which is down.

      7:46:01,647 DEBUG [org.hornetq.core.client] (http-lxsjbslb02.xoominfo.com/10.31.160.38:8080-4) Trying to connect at the main server using connector :TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com

      17:46:01,647 DEBUG [org.hornetq.core.client] (http-lxsjbslb02.xoominfo.com/10.31.160.38:8080-4) Remote destination: lxsjbshq01.xoominfo.com/10.31.160.99:5445

      17:46:01,651 DEBUG [org.hornetq.core.client] (http-lxsjbslb02.xoominfo.com/10.31.160.38:8080-4) Main server is not up. Hopefully there's a backup configured now!

      17:46:03,651 DEBUG [org.hornetq.core.client] (http-lxsjbslb02.xoominfo.com/10.31.160.38:8080-4) Trying reconnection attempt 14/15

      17:46:03,652 DEBUG [org.hornetq.core.client] (http-lxsjbslb02.xoominfo.com/10.31.160.38:8080-4) Trying to connect with connector = org.hornetq.core.remoting.impl.netty.NettyConnectorFactory@6edd9715, parameters = {port=5445, host=lxsjbshq01.xoominfo.com} connector = NettyConnector [host=lxsjbshq01.xoominfo.com, port=5445, httpEnabled=false, useServlet=false, servletPath=/messaging/HornetQServlet, sslEnabled=false, useNio=false]

      17:46:03,652 DEBUG [org.hornetq.core.client] (http-lxsjbslb02.xoominfo.com/10.31.160.38:8080-4) Started Netty Connector version 3.6.2.Final-c0d783c

      17:46:03,652 DEBUG [org.hornetq.core.client] (http-lxsjbslb02.xoominfo.com/10.31.160.38:8080-4) Trying to connect at the main server using connector :TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=lxsjbshq01-xoominfo-com

        • 1. Re: hornetq client failover
          hasmik.sarkezias

          For anyone that might have similar issues, I figured out  my problem. ..

           

          The reconnectOnException should be set to false!! It's obvious when you know the problem.

           

          <bean name="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" lazy-init="true">
             <property name="targetConnectionFactory" ref="hornetJmsConnectionFactory" />
             <property name="sessionCacheSize" value="5" />
             <property name="reconnectOnException" value="false"/>
             <property name="exceptionListener" ref="hornetqJmsExceptionListener"/>

              </bean>