So basically my app does some processing of stuff in intervals every 1 second. I have to implement a SIGTERM signal to my app but I have to let the stuff that is currently being processed in app to FINISH and then the app can terminate. Therefore I'm looking for something like a try{}catch{} but for SIGTERM, I would do a sleep for few seconds and then let the SIGTERM terminate the app, is there something like that?
As far as I know @PreDestroy closes whole context and then leaves one bean annotated with it, executes it and then destroys.
Also the addShutdownHook() is a method to be run when shutting down app, but I just want my main processing to finish and then shutdown everything.
Is there a way to do it?