During startup scheduled tasks are driven earlier than before causing problems with Spring Batch [SPR-12641] #17242
Comments
Juergen Hoeller commented I'm afraid there isn't much we can do on the Spring Framework side here, since the use of Which tasks typically depend on the registration of Batch jobs? Is there anything Spring Batch can do to register its jobs earlier, possibly in a Juergen |
Andy Wilkinson commented The main problem here is that this change has caused a regression in an application that worked fine on Spring Boot 1.1.x which uses Spring 4.0.x. I'd like us to have a better answer than asking the user the change their code. Perhaps the Batch team can detect the presence of Spring 4.1 and do things earlier? |
Michael Minella commented Juergen Hoeller, I had a chat with Andy Wilkinson and Dave Syer about this. In reading the documentation for
Isn't that exactly what is being done here? If so, I'd think that Looking at the current batch code, the class in question is the At a minimum, if |
Juergen Hoeller commented Resolved though making Please give this a try with Batch and Boot against the next 4.1.5 snapshot... Juergen |
Andy Wilkinson commented Thanks, Juergen. I can confirm that the problem reported in Spring Boot 2310 is fixed when run with 4.1.5.BUILD-20150123.212042-11. |
Andy Wilkinson opened SPR-12641 and commented
Spring Batch performs it job registration in response to a
ContextRefreshedEvent
. In Spring 4.0, the scheduler starts calling scheduled tasks in response to aContextRefreshedEvent
. In Spring 4.1 the latter has changed due #16655 which madeScheduledAnnotationBeanPostProcessor
aSmartInitializingSingleton
. In short this means that the scheduler now starts calling scheduled tasks before theContextRefreshedEvent
is sent. This means that scheduled tasks that are driven during startup can no longer depend on a Batch job having been registered.Affects: 4.1.4
Reference URL: spring-projects/spring-boot#2310
Issue Links:
Referenced from: commits 0479ca6, 14a3bf3
0 votes, 6 watchers
The text was updated successfully, but these errors were encountered: