5 Replies Latest reply on Oct 6, 2011 2:38 PM by clebert.suconic

    HornetQ HA using Core API doesnt failover

    amit.gupta14

      Hi,

      I tried to use HA using Core API which worked fine on Windows machine when I tried same code on Linux machine it didnt failed. Servers are working fine on both Windows and on Linux but Client is not failing over. 

      serverLocator

      = HornetQClient.createServerLocatorWithHA(transportConfig1, transportConfig2);

       

      Code works fine both on Windows and on Linux using JMS API.

       

      Thx

        • 1. Re: HornetQ HA using Core API doesnt failover
          clebert.suconic

          All the JMS Layer is doing is the same call you are making.

           

          I would need to see some code to tell you exactly what are you doing differently.

          • 2. Re: HornetQ HA using Core API doesnt failover
            amit.gupta14

            Map<String,Object> connectionParams1 = new HashMap<String,Object>();
            connectionParams1.put(TransportConstants.HOST_PROP_NAME, 127.0.0.1);
            connectionParams1.put(TransportConstants.PORT_PROP_NAME, 5445);
            TransportConfiguration transportConfiguration1 = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams1);

            Map<String,Object> connectionParams2 = new HashMap<String,Object>();
            connectionParams2.put(TransportConstants.HOST_PROP_NAME, 127.0.0.1);
            connectionParams2.put(TransportConstants.PORT_PROP_NAME, 5447);
            TransportConfiguration transportConfiguration2 = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams2);

            serverLocator = HornetQClient.createServerLocatorWithHA(transportConfiguration1, transportConfiguration2);
            serverLocator.setRetryInterval(1000);
            serverLocator.setRetryIntervalMultiplier(1.0);
            serverLocator.setReconnectAttempts(1);


            clientSessionFactory = serverLocator.createSessionFactory();
            clientSession = clientSessionFactory.createSession(userName, password, false, true, true, true, 1);
            clientSession.start();

             

            Unfortunately above code didn’t worked on Windows, but after putting below patch it worked on Windows for failover. But its not working on Linux, when both servers and client run on Linux.

            Corresponding code works for JMS API both on windows and Linux.

            for(int j=0;j<4;j++) {
            if(clientSessionFactory != null)
              clientSessionFactory.close();
            clientSessionFactory = serverLocator.createSessionFactory();
            }

             

            • 3. Re: HornetQ HA using Core API doesnt failover
              amit.gupta14

              Its working fine now. Fix is to remove second entry transportConfiguration2 which points to backup server. Very strange, I dont know why it works on Windows but not on AWS Linux node.

              • 4. Re: HornetQ HA using Core API doesnt failover
                amit.gupta14

                Hi,

                Conclusion:

                Real culprit was serverLocator.setReconnectAttempts(1); I increased it to 10, transportConfiguration2 is fine.

                 

                Thnx

                • 5. Re: HornetQ HA using Core API doesnt failover
                  clebert.suconic

                  Most of the time I have seen it set to -1

                   

                   

                  But each use case is different, right? Just a thought!