How to prevent Spring context closing until clustered Quartz jobs are not finished ? [ Spring + Quartz ]

697 Views Asked by At

I developed an application with Spring boot 2.2.4.RELEASE and Quartz (v 2.2.3) in the cluster. I have a Master Job that finds the records in a table and schedule these records via scheduler

`org.springframework.scheduling.quartz.SchedulerFactoryBean

Every single job scheduled has a logic that interacts with DB via HikariCP (Connection pool). The rule must be that in case of application shut-down the application has to wait until the end of every running job. I will be able to set this rule to

org.springframework.scheduling.quartz.SchedulerFactoryBean

via property setWaitForJobsToCompleteOnShutdown(true); `

The solution it's working fine but I saw that the Connection Pool (HikariCP) is closed without to wait for the end jobs to run. It leads to the loss of the interaction logicon DB. I'd like to avoid this thing.

During shut-down of Spring boot, is it possible to prioritize the objects close into the context to do to finish every single job process regularly ?

0

There are 0 best solutions below