I have a Wildfly-10.1.0 server that has a set of clients connected to them by means of https-remoting.
The clients receives notifications from the server using ActiveMQ which is initiated over the https-remoting pipe on 8443.
I have migrated the server from a JBoss-4.2.3 server where this functionality was implemented with a Runtime.getRuntime().addShutdownHook( ... );
This however does not work in the Wildfly server because, well it is simply better :-)
I want to send a Notification before the server shuts down like: shutdown-signal -> send shutdown notification -> wait 2-3 secs for clients to receive the event -> proceed with the shutdown.
I have found that I could use the org.jboss.as.server.suspend.SuspendController to add OperationListener and send it on listener.suspendStarted().
But how do I get hold of the SuspendController?
What I have figured so far is to implement an extension to Wildfly so that I can get hold of the OperationContext and from there do context.getServiceRegistry(false).getService( SuspendController.SERVICE_NAME );
Thats a ridiculous amount of code for one event.
So my question: is that the only way?
Can't I get the SuspendController from the JNDI, inject it into my bean or just get the service registry through some wonderful static method?
Has nobody encountered or tried to do this?