Gracefully shutdown JBoss application

时间:2016-10-19 13:41:19

标签: java jboss wildfly jmx wildfly-8

I am looking for an approach to gracefully handle shutdown of JBoss (Wildfly AS 8.2). This would mean that all current requests are served and the webapp stops receiving further requests. I found that this is possible via command line in version 9 of the application server -

./jboss-cli.sh --controller=remoting://<host>:<port> 
--connect --command=:shutdown(timeout=t)

Using this JBoss gracefully handles all requests for t seconds and gracefully shuts down (this would require an upgrade from version 8 to 9).

One possible approach would be to handle this in the Java application by maintaining a count of active requests and waiting for this number to go to 0 till a timeout and then exitting, basically replicating the above mentioned functionality.

I need to shutdown the webapp/JBoss remotely, so we are looking for a JMX (Java Management Extension) based solution. Does JBoss expose any such operation to gracefully shut down possibly via JMX or any other technology?

PS- Ctrl-C or kill commands donot shutdown JBoss gracefully.

1 个答案:

答案 0 :(得分:-1)

您可以远程使用Jboss cli作为您在控制器参数显示中传递的URL。您甚至可以使用“REST”API来执行它。 关闭应该可以从JMX获得。