Allow customization of Spring Batch TaskExecutor #29296
Closed
+211
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses some concerns I raised in #27899, taking the discussion therein into account. My primary objective is to make it easier for newcomers to use Spring Batch properly.
Currently, the support for Spring Batch is geared towards single-job containerized Spring Boot apps orchestrated by a job scheduler. I pointed that out in the docs because it's not obvious. I also added a note that using Spring Batch as part of a web app is a viable option but that it requires some configuration, namely configuring an asynchronous
TaskExecutor
. Doing that is awkward because it requires overriding eitherBasicBatchConfigurer
orJpaBatchConfigurer
. Picking the right one requires knowledge about the Spring Batch auto-configuration. To avoid that I introduced@BatchTaskExecutor
(modeled after@BatchDataSource
). Thanks to@BatchTaskExecutor
, swapping theTaskExecutor
used by Spring Batch is now a matter of defining an additional bean.