I am migrating from JBoss 6.1.0_final to WildFly 10. On a certain condition, I want to stop my server. Like:
if (condition == true)
System.exit(1);
The above code works fine in JBoss, it shuts down the server immediately.
But when I exeute the same in WildFly10, the server does not stop immediately.
It sends the shutdown signal, then unbound datasource then JMX and so on. I found can be done by MBeans but not working here: https://developer.jboss.org/thread/198579. This gives some error like:
params and description have different lengths
I want to stop my WildFly10 server immediately. Any one have done something like this?
The following should work (just handle the exceptions):
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName("jboss.as:management-root=server");
mBeanServer.invoke(objectName, "shutdown", new Object[] { false, 0 },
new String[] { boolean.class.getName(), int.class.getName() });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With