I'm connecting MongoDB with Spring boot application, and my situation is that MongoDB goes down unexpectedly and throws connection exception, mongodb connection timeout exception and socket exception.
I'd like to capture the above exception in spring boot, and shutdown the app. I tried with @schduled from HealthIndicator which executes a simple command in DB for every 3sec and captures general exception, it works but it's not a correct approach because gives plenty of loads with multiple instances.
Unfortunately i couldn't use @controlleradvice and @exceptionhandler because don't want throwing any exception by executing query. The hitting DB with query gives loads to DB with multiple instances.
Is there any way to handle my situation?