I have a report generating application. As preparation of such reports is heavyweight, they are prepared asynchronously with Spring Batch. Requests for such reports are crea
SimpleAsyncTaskExecutor
isn't recommended for heavy use since it spawns a new thread with each task. It also does not support more robust concepts like thread pooling and queueing of tasks.
If you take a look at the ThreadPoolTaskExecutor
, it supports a more robust task execution paradigm with things like queueing of tasks and using a thread pool instead of spawning random, un-reused threads.
You can read more about the ThreadPoolTaskExecutor
in the javadoc here: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.html
That helped, many thanks. After replacing SimpleAsyncTaskExecutor I have exactly what I need. Code:
@Bean
public TaskExecutor jobLauncherTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setMaxPoolSize(executorsPoolSize);
executor.setCorePoolSize(executorsPoolSize);
return executor;
}
Thanks f