Calling a closing method in spring boot application is the tomcat server is shut down -


i have spring boot application can shut down anytime manually user. application pushes data messaging queue read file. want call method should persist state upto the file read if application shut down.

you can use spring boot shutdown hook logic yourself.

application exit

each springapplication register shutdown hook jvm ensure applicationcontext closed gracefully on exit. standard spring lifecycle callbacks (such disposablebean interface, or @predestroy annotation) can used.

in addition, beans may implement org.springframework.boot.exitcodegenerator interface if wish return specific exit code when application ends.

23.8 application exit


Comments