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.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 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)?