8 Replies Latest reply on Nov 16, 2009 2:55 PM by Vinay Pothnis

    Fail to run AutomaticFailoverExample

    anthony lee Newbie

      Hi ,
      Before I ran this example, I changed server1's configuration files to point to my Ubuntu IP(this is my live sever) and put the backup server as my windowsXP IP(this runs on a virtualBox over Ubuntu), and then I changed target 'run' ant file build.xml by set parameter 'hornetq.example.beans.file' as 'server1'. After I removed data dir on live server and backup server, I ran backup server first, and then run build.xml in JBoss Studio, in this way, everything is OK.
      But if I comment statement 'killServer(1)' in class AutomaticFailoverExample and try to manually kill the process in Ubuntu terminal, I saw the failure detection log but the backup server didn't print out receive connection request and become alive like it did before killServer(1) is commented. So it fail because the old connection is broken and client didn't try to get connection from backup server.
      And I try to change the implementation of killServer, so I changed statement in run() of class KillChecker in package org.hornetq.common.example: Runtime.getRuntime().halt(666) changed as Runtime.getRuntime().exit(666).
      Then I ran this example again, this time it fail just like I killed live server manually.

      Any ideas are appreciated.
      Anthony

        • 1. Re: Fail to run AutomaticFailoverExample
          Clebert Suconic Master

          This is a place being heavily changed before next release.

          I would wait the release, or if you really want to take a look, check out trunk, and build a release to look at how it is done now. We still have some docs to change before the release, but I think is pretty accurate now:


          You can do:

          svn co http://anonsvn.jboss.org/repos/hornetq/trunk/
          cd trunk
          ./build.sh distro


          and use the distribution generated under ./build.

          • 2. Re: Fail to run AutomaticFailoverExample
            anthony lee Newbie

            My question is :
            For HornetQ's current version, to get fail over functionality, does it matter how I shutdown the live server ?

            • 3. Re: Fail to run AutomaticFailoverExample
              Tim Fox Master

              What have you set the attribute FailoverOnServerShutdown too? (see user manual).

              How did you manually "kill" the server? If you did CTRL-C that's not actually a kill, it will start an orderly shutdown of the server.

              Default value of this attribute is false

              public static final boolean DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN = false;

              • 4. Re: Fail to run AutomaticFailoverExample
                anthony lee Newbie

                Hi,
                Thanks for reply.

                What have you set the attribute FailoverOnServerShutdown too? (see user manual).
                ----I didn't set this attribute.
                The example fail to run only because I change the way to shutdown server.

                How did you manually "kill" the server? If you did CTRL-C that's not actually a kill, it will start an orderly shutdown of the server.
                ---Yes, I used CTRL-C to shutdown the server in Ubuntu terminal.
                1. Does it mean if the server is orderly shutdown failoverexample's client will fail to send connection request to backup server?
                2. Would you tell me how to shutdown the server in other way?

                • 5. Re: Fail to run AutomaticFailoverExample
                  Tim Fox Master

                  This is explained in section 39.2 of the user manual:

                  http://hornetq.sourceforge.net/docs/hornetq-2.0.0.BETA5/user-manual/en/html/ha.html


                  Sometimes you want a client to failover onto a backup server even if the live server is just cleanly shutdown rather than having crashed or the connection failed. To configure this you can set the property FailoverOnServerShutdown to false either on the HornetQConnectionFactory if you're using JMS or in the hornetq-jms.xml file when you define the connection factory, or if using core by setting the property directly on the ClientSessionFactoryImpl instance after creation. The default value for this property is false, this means that by default HornetQ clients will not failover to a backup server if the live server is simply shutdown cleanly.



                  • 6. Re: Fail to run AutomaticFailoverExample
                    Tim Fox Master

                    "Killing" the server means either killing the server process, e.g. killall -9 java on the server, or pulling the network plug for more than clientFailureCheckPeriod

                    • 7. Re: Fail to run AutomaticFailoverExample
                      anthony lee Newbie

                      Yes, It works using kill -9 pid.

                      Thanks a lot, Tim.

                      • 8. Re: Fail to run AutomaticFailoverExample
                        Vinay Pothnis Newbie

                        Hello,

                        I am trying to run the automatic failover example provided with the distribution. I executed "ant" at the "automatic-failover" directory and I get the following error:

                         [java] HornetQServer_0 err:[Thread-2 (group:HornetQ-server-threads3205962-2898048)] 11:50:52,257 INFO [org.hornetq.core.server.impl.HornetQServerImpl]
                         Backup server is now operational
                         [java] HornetQServer_1 err:[Main Thread] 11:50:52,304 INFO [org.hornetq.core.server.impl.HornetQServerImpl] HornetQ Server version 2.0.0.BETA5 (horne
                        t-baby, 108) started
                         [java] HornetQServer_1 out:STARTED::
                         [java] Nov 16, 2009 11:50:52 AM org.hornetq.common.example.HornetQExample getContext
                         [java] INFO: using server1\client-jndi.properties for jndi
                         [java] Sent message: This is text message 0
                         [java] Sent message: This is text message 1
                         [java] Sent message: This is text message 2
                         [java] Sent message: This is text message 3
                         [java] Sent message: This is text message 4
                         [java] Sent message: This is text message 5
                         [java] Sent message: This is text message 6
                         [java] Sent message: This is text message 7
                         [java] Sent message: This is text message 8
                         [java] Sent message: This is text message 9
                         [java] Killing server 1
                         [java] Nov 16, 2009 11:50:53 AM org.hornetq.core.logging.Logger warn
                         [java] WARNING: Connection failure has been detected: Netty exception [code=0]
                         [java] Nov 16, 2009 11:50:53 AM org.hornetq.core.logging.Logger warn
                         [java] WARNING: Connection failure has been detected: Netty exception [code=0]
                         [java] javax.jms.JMSException: Timed out waiting for response when sending packet 74
                         [java] at org.hornetq.core.remoting.impl.ChannelImpl.sendBlocking(ChannelImpl.java:304)
                         [java] at org.hornetq.core.client.impl.ClientConsumerImpl.doCleanUp(ClientConsumerImpl.java:745)
                         [java] at org.hornetq.core.client.impl.ClientConsumerImpl.close(ClientConsumerImpl.java:315)
                         [java] at org.hornetq.jms.client.HornetQMessageConsumer.close(HornetQMessageConsumer.java:335)
                         [java] at org.hornetq.jms.client.HornetQSession.close(HornetQSession.java:457)
                         [java] at org.hornetq.jms.client.HornetQConnection.close(HornetQConnection.java:446)
                         [java] at org.hornetq.jms.example.AutomaticFailoverExample.runExample(AutomaticFailoverExample.java:129)
                         [java] at org.hornetq.common.example.HornetQExample.run(HornetQExample.java:73)
                         [java] at org.hornetq.jms.example.AutomaticFailoverExample.main(AutomaticFailoverExample.java:36)
                         [java] Caused by: HornetQException[errorCode=3 message=Timed out waiting for response when sending packet 74]
                         [java] ... 9 more
                         [java]
                         [java] #####################
                         [java] ### FAILURE! ###
                         [java] #####################
                         [java] Java Result: 1
                        
                        BUILD FAILED
                        C:\Tools\HornetQ-2.0.0.BETA5\examples\jms\automatic-failover\build.xml:23: The following error occurred while executing this line:
                        C:\Tools\HornetQ-2.0.0.BETA5\examples\common\build.xml:142: Example org.hornetq.jms.example.AutomaticFailoverExample failed
                        


                        Any inputs on this?

                        -Thanks
                        Vinay