I have Spring boot application, that goes to database using HikariCP (several threads use it).
The thing is, when application gets stop (SIGTERM) signal, it must go to database and change some data, after that it can be closed ("gracefull shutdown"). This logic is written in myShutdownHook Runtime.getRuntime().addShutdownHook(myShutdownHook). So the app needs to use connection pool for that. But problem is that Hikari pool closes right after getting stop signal:
18:26:44,796 INFO [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Shutdown initiated...
18:26:44,798 INFO [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Shutdown completed.
And context is closing before my logic is completed. How can I go to database and change data there after getting shutdown signal, but before connection pool and application context closed?