-
Notifications
You must be signed in to change notification settings - Fork 41k
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
Cannot create asynchronous JobLauncher #1655
Comments
How funny, i was having this problem just yesterday as well, with regular Spring. I was able to create my own SimpleJobLauncher by overriding the getJobLauncher() method and returning my own lazily-initialized instance. However my code breaks if I set a TaskExecutor that uses different threads.. probably just my implementation though. |
One option is to declare your own bean that implements To help with that, we could perhaps make |
You mean |
In my case, I'm launching job from REST API, so I have to @Bean
public JobLauncher asyncJobLauncher() {
SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
jobLauncher.setJobRepository(jobRepository);
jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
return jobLauncher;
} Pay attention on bean name, I must not be @Autowired
@Qualifier("asyncJobLauncher")
private JobLauncher jobLauncher It's not clean but a bit easier than overriding whole But I'm waiting for a real solution |
@kakawait - I think i need to kiss you for this code 👍 |
Hi @kakawait, What I did was:
Help will be appreciated, Thanks, |
@tomerku this tracker is not the right place for asking such question. Please ask them on Stackoverflow. |
Will do. Thanks. |
Actually, I think this issue can be closed. |
The Spring Boot implementations does not set any
TaskExecutor
so it defaults toSyncTaskExecutor
. And there is no way (as I know) to override the defaultjobLauncher
bean because of this line inBasicBatchConfigurer
which creates a defaultjobLauncher
:I also tried to autowire
jobLauncher
and set theTaskExecutor
by myself. But because I can only autowire the interface, I can't calljobLauncher.setTaskExecutor(simpleAsyncTaskExecutor)
.The text was updated successfully, but these errors were encountered: