Is there a way in Spring Boot to control the graceful shutdown of the app?
I know that you can have @PreDestroy
methods in beans, but how can you control the ordering in which those @PreDestroy
methods are called?
You can have multiple beans depending on each other will the shutdown of the context look for this dependency already and call the @PreDestroy
methods in the right order or not?
For example what I would like to accomplish is:
1) stop listening for new requests on rest endpoints
2) prevent rabbit message listeners to accept new messages
3) wait for all processing that has started before the shutdown but is not finished yet.