Wait for Quartz jobs to finish before continuing shutdown of singleton beans [SPR-14806] #19372
Comments
Nicolas Labrot commented Hello, Is there a status about this issue? Thanks |
Nicolas Labrot commented This issue could be closed: it is not a spring data one but a spring SchedulerFactoryBean one. The SchedulerFactoryBean#stop method calls the quartz standby method which does not wait for job completion. Thus, Spring continues its shutdown process and it starts to destroy singletons and especially the auditingHandler bean before the schedulerFactoryBean bean. Thus when a job completes and commits, auditingHandler has already been destroyed. |
Oliver Drotbohm commented Thanks for the heads up, Nicolas. Do we have an upstream ticket for Spring Framework actually? Otherwise I could just turn this one into a Spring Framework one. |
Nicolas Labrot commented Yes please, but as an improvment |
Oliver Drotbohm commented Do you have ticket ID handy? I couldn't find anything on a quick search. |
Nicolas Labrot commented Sorry I mean you could turn this ticket into a Spring Framework one. |
Oliver Drotbohm commented Moved, updated the description and assigned to Jürgen for further triage. |
Juergen Hoeller commented Our Alternatively, |
Nicolas Labrot commented The shutdown thread is already blocked when using
These thoughs seems applicable to |
Juergen Hoeller commented There is a conceptual problem here in that As for So from that perspective, the root of the problem remains that some scheduled tasks depend on the availability of further beans that they are not directly referring to. Since declared/resolved dependencies are taken into account already, it's only really about implicitly used beans such as the audit listener in your transaction setup. The proper solution seems to be to explicitly declare the |
Nicolas Labrot commented I agree mostly with your comment. My cons are:
What do you think of a For example here is an adapted code snippet from one of my integration test:
Further investigation may be need in order to check that after the |
Nicolas Labrot commented After a I'm not sure that explicit bean dependency will solve the issue because I'm using a I have created this quartz issue Add a method to return true when the QuartzSchedulerThread is actually paused and created a custom Thanks |
Bulk closing outdated, unresolved issues. Please, reopen if still relevant. |
Nicolas Labrot opened SPR-14806 and commented
This one originated as ticket in Spring Data but the essence seems to be this:
Original description
Hello,
When my application shutdown I got this exception:
Some tasks must be finished prior to the shutdown and because spring is shutting down, it forbids call to DefaultSingletonBeanRegistry#getSingleton and thus AuditingEntityListener#touchForUpdate failed because he used an ObjectFactory<AuditingHandler>:
Issue Links:
The text was updated successfully, but these errors were encountered: