Adding shutdown hook for RMI Client
843793Oct 26 2004 — edited Oct 27 2004Hello,
I am trying to figure out the best way to implement a shutdown procedure for an RMI client that allows cleanup/persistance to happen. My environment is solaris and currently the RMI clients run from a sript that starts the client in the background using a nohup command. During testing for the system, we have just used kill process commands to stop the client.
Since the client could be doing work at the time of the kill command, this is not optimal for our situation. We have implemented a graceful shutdown process on the RMI server that can be called from a shutdown program to notify the server to stop. This works great for stopping the server. I would like to have the same functionality to stop a single client within the system.
I have searched for a while on this topic and it appears an o/s kill command doesn't get communicated from the jvm to the java application so there isn't anyway to catch this before the process is stopped. I could create an exported object on the client that uses the same design to shutdown our RMI server, but I am wondering if there is another way besides RMI to gracefully shutdown a java application.
Thank you in advance for any thoughts or advice.
Todd