I am now using @EnableAsync
and @Async
annotation to use multithreaded in Spring Boot. I have service A(fast) and service B(slow).
How can I set different pool for them? So when there are lots of calls for B, the application can still handle service A in a different pool from B.
@Configuration
@EnableAsync
public class ServiceExecutorConfig implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(30);
taskExecutor.setMaxPoolSize(40);
taskExecutor.setQueueCapacity(10);
taskExecutor.initialize();
return taskExecutor;
}
}