-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce @BatchTaskExecutor to make it easier to configure Spring Batch to use a custom task executor #40040
Comments
I think we could achieve this by having Lines 444 to 470 in 7c4ce13
|
@wilkinsona correct me if I'm wrong, but this won't work because then you'd get duplicate beans: one from the superclass an one from your subclass. import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
val context = SpringApplication.run(DemoApplication::class.java, *args)
println(context.getBean("text"))
}
@Configuration(proxyBeanMethods = false)
class SuperBeans {
@Bean
fun text() = "Hello"
}
@Configuration(proxyBeanMethods = false)
class SubBeans : SuperBeans() {
@Bean
override fun text() = "World"
} Results in
|
@micheljung this works fine as shown by the Spring MVC example to which I have linked above. The arrangement you've shown isn't the same as we've used in |
This is a valid point. Currently, as a boot user, I can provide a batch datasource and it will be set on the job repository, without having to (re)define the job repository. I should be able to do the same with the task executor of the job launcher, meaning I should be able to specify a task executor to use for batch without having to define the job launcher. However, in my experience with users mixing web requests and batch workloads (ie running batch jobs in the same JVM as the servlet container), it is common that people do not want to use the same thread pool for web and batch requests (different pool sizes, different prefixes, etc). Therefore, it should be possible to specify a dedicated task executor for batch. What about a new annotation |
Have you got a chance to think about this? I believe it is the easiest, most straightforward and consistent approach to tackle the problem. If you agree on the idea, is it possible to include it in Boot 3.4 (Batch 5.2)? |
With only a week to go before RC1, Boot 3.5 is the more likely at this point I'm afraid. |
I was a week ahead of myself so we had a bit more time than I thought.
I think this is a good idea. It's less involved than overriding I'll see if we can get this into 3.4 after all. |
This is fantastic! Thank you very much, @wilkinsona. |
Pretty cool! |
This is #1655 again, with the catch that
BatchConfigurer
(BasicBatchConfigurer
?) is not available in Spring Boot 3. Therefore, the Spring Boot autoconfigured Spring BatchJobLauncher
'sTaskExecutor
cannot be directly customized at all. Users can only provide an alternativeJobLauncher
bean, as demonstrated in that issue, or forgo Spring Boot's autoconfiguration entirely.The practical impact of this does not appear significant. It is evident from inspecting the autoconfiguration that it is aimed at command line runners, where synchronous execution seems reasonable to me. In a web context synchronous execution is possibly an acceptable default (debatable, but all right) but the inability to switch to asynchronous execution is not acceptable, however, the autoconfiguration does not help a web context much at all so opting out of it is a minor issue.
Although I think the executor should be possible to configure I might well argue that the bigger issue is that the Spring Boot reference documentation could be clearer about where the autoconfiguration is useful and where it is preferable to skip it.
The text was updated successfully, but these errors were encountered: