4 Replies Latest reply on Feb 3, 2015 6:39 AM by Angelo Fuchs

    Configure Shutdown of JBoss 7.1

    Angelo Fuchs Newbie


      I want to configure the actions the JBoss performs on shutdown. Yet, I can’t find the proper configuration elements for the standalone.xml. I need to configure the shutdown timeout and require Resources (JMS, Database) to be available up until then.


      My situation is that I have multiple JBoss 7.1 instances running, they are connected in the way as described in the standalone-full-ha.xml example file. That works good as long as the servers are up. But now I want to ensure the correct behavior of my beans on shutdown of the server. The most relevant element being that I have beans that run for a prolonged period of time (hours, days…). They can be stopped but that too takes some time ( ~30 seconds) and requires that the Resources for the Beans are still available during that time. The work gets started through MDBs. “Stopped” here means that they transfer their work to a different node. A failover (and with that a restart of the work) is not sufficient.


      I thought it would be good to bring the JBoss in a state where it delegates all incoming JMS Messages to the next instance (so no new work gets started). As part of the shutdown process of my Beans is to start some cleanup functions (that take longer) via a JMS Message I would like to be certain that it starts on a different node than the one I want to shutdown.


      As far as I have understood the EJB 3.1 specification the resources that I get injected via @Resource are protected from being closed as long as a @Singleton references them, as long as that singleton has a @PreDestroy that has not yet finished.

      I wrote a simple ejb-jar that contains a @Singleton that has two @Resource elements (Connection Factory and Queue) that get used by my long runner method.


      So, when I undeploy my ejb-jar the situation works (more or less) like expected. I get the following exception after my function completes, but the function completes.

      15:20:35,541 ERROR [org.hornetq.core.client.impl.ClientConsumerImpl] (Thread-3 (HornetQ-client-global-threads-25134311)) Failed to call onMessage(): java.lang.NullPointerException 
      at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:336)
      at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:983) [hornetq-core-2.2.13.Final.jar:]
      at org.hornetq.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:48) [hornetq-core-2.2.13.Final.jar:]
      at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1113) [hornetq-core-2.2.13.Final.jar:]
      at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100) [hornetq-core-2.2.13.Final.jar:]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
      at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]

      But if I shut down one server, the Connection Factory seems to close prematurely and I get this Exception:

      15:23:16,500 Schwerwiegend [singletons.WorkerSingleton] null: javax.jms.JMSException: Failed to create session factory
      at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
      at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
      at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:114)
      at singletons.MessagingSingleton.sendMessage(MessagingSingleton.java:43) [SingletonTests-ejb.jar:]

      (singletons.MessagingSingleton is the test-class of mine)


      So I want to configure JBoss to initiate shutdown (as it properly does, JMS Messages get send to the next node), then wait for a minute before tearing down the Connection Factory (and other Resources).


      How can I do so? Or alternatively, is there a complete documentation of all parameters for the standalone.xml (like the Javadoc for the JDK)?

        • 1. Re: Configure Shutdown of JBoss 7.1
          Tomaz Cerar Master

          What you are after is called "graceful shutdown" and is one of main features we are working on in WildFly 9 which is currently in development.


          It would be great if you could test nightly builds and provide feed back if everything works as you want it to work.


          As part of this we added additional parameter "timeout" to :shutdown operation that does just as you want.

          • 2. Re: Configure Shutdown of JBoss 7.1
            Angelo Fuchs Newbie

            I will test WildFly 9. But some of our customers are using JB7.1, so I need to figure this out . How do I apply timeout?

            I tried:

            jboss-cli.bat --connect command=:shutdown timeout=60000 controller=

            but it gives me the error

            Duplicate argument '--command'/'--commands'.

            If I leave the timeout=60000 then it shuts down the instance at once.

            I also tried:

            changing the order of the arguments, prepending the arguments with "--", replacing "command" with "commands" and various others.

            If I write the commands like this: "commands=:shutdown,timeout=60000" it shuts down immediately and says it does not recognize timeout as argument. ":shutdown --timeout" or variations thereof don't work either. ":shutdown(timeout=60000)" doesn't work either, giving result: 'timeout' is not found among the supported properties: restart


            I have a JBoss AS release: 7.1.1.Final "Brontes"

            • 3. Re: Configure Shutdown of JBoss 7.1
              Tomaz Cerar Master

              there is no timeout prior 9.


              in 9 you can do :shutdown(timeout=600)

              1 of 1 people found this helpful
              • 4. Re: Configure Shutdown of JBoss 7.1
                Angelo Fuchs Newbie

                Thank you, knowing that it's not possible is much better then trying and failing .

                I'll inform our customers that they need to upgrade to WF9 if they want to use this feature as soon as its stable.


                FYI: I summarized this thread here: http://stackoverflow.com/a/28295472/881272