Sometimes, tomcat restart will cause my application stop immediately so that my consuming data in oracle db keep one error state. So I want know if has any methods to help handling the state once the tomcat stop. Due to unknown the actual events happen on the stop procedure of tomcat. I can’t know how to make sure something happen when tomcat stopped.
Sometimes, tomcat restart will cause my application stop immediately so that my consuming data
Share
If you are doing a normal restart you should be able to register a shutdownhook and have it run before the server kills the app.
Check out the javadocs for more detailed info: http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread).
You can add a shutdown hook like this: