-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Multi-threaded Step job hangs if @StepScope bean cannot be created #3948
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
Comments
Thank you for reporting this issue. I do confirm that the That said, I see no added value in making the |
We do see added value in making the |
You can do that with a system property (or a similar mechanism provided by Spring Framework or Spring Boot), something like: -- $>java -jar myjob.jar poolSize=3
++ $>java -jar myjob.jar -DpoolSize=3 @Bean
-- @StepScope
-- public TaskExecutor taskExecutor(@Value("#{jobParameters['poolSize']}") int poolSize) {
++ public TaskExecutor taskExecutor(@Value("#{systemProperties['poolSize']}") int poolSize) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(poolSize);
executor.setMaxPoolSize(poolSize);
return executor;
} |
Uh oh!
There was an error while loading. Please reload this page.
If in a multi-threaded step a @StepScope bean cannot be created then the batch just hangs waiting in TaskExecutorRepeatTemplate#waitForResults L172.
In my batch I want to pass in the pool size as a job parameter to the TaskExecutor used in the step. If this parameter is missing or cannot be converted into an int, then an exception is added to the deferred list but the TaskExecutorRepeatTemplate thinks a result is still coming from the ResultQueueResultHolder.
Here is my task executor:
Here's a pull request demonstrating the problem:
Apress/def-guide-spring-batch#13
The text was updated successfully, but these errors were encountered: