1 Reply Latest reply on Aug 19, 2013 6:30 PM by clebert.suconic

    Upgrading Hornetq 2.1.1.Final to 2.3.0

    dheinzh3

      I'm upgrading to the latest version of HornetQ 2.3 and am interested in knowing how to properly shutdown a 2.3 stand alone server.

       

      Our server currently running under 2.1.1  is a very simple app  -- Here is the code

       

      package com.hcm.distributionservice.impls.hornetqcore;

       

      import org.hornetq.integration.bootstrap.HornetQBootstrapServer;

      import org.jboss.kernel.spi.config.KernelConfig

       

      /**

      * Just a wrapper around the HornetQBootstrapServer class in case

      * we want to put in anyspecific code.

      *

      *

      */

      public class HCMHornetQBootstrapServer extends HornetQBootstrapServer

      {

                public HCMHornetQBootstrapServer(KernelConfig kernelConfig, String... args) throws Exception

                {

                          super(kernelConfig, args);

                }

       

       

                public HCMHornetQBootstrapServer(String... args) throws Exception

                {

                          super(args);

                }

       

                public void start()

                {

                          run();

                          addShutdownHook();

                }

       

       

                public static void main(String[] args) throws Exception

                {

                          new HCMHornetQBootstrapServer(args).start();

                }

      }

       

       

      However, the method addShutDownHook() is no longer visible in 2.3. So, how do I shutdown my standalone server in the proper manner?   Does 2.3 shut down all the bits and pieces for me?   I'm guessing not because, in the examples directory in the 2.3 installation, there is this set of code.       Maybe I should be using Runtime.getRuntime().addShutdownHook()   ?   Is that safe to do?

       

       

                  // Step 8. Be sure to close our resources!

                  if (sf != null)

                  {

                     sf.close();

                  }

       

       

                  // Step 9. Shutdown the container

                  if (hornetQ != null)

                  {

                     hornetQ.shutDown();

                  }

       

      Thank you.