I've configuration that is implementing AsyncConfigurer as bellow:
@Configuration
@EnableAsync
public class AsyncConfiguration implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setMaxPoolSize(5);
executor.setCorePoolSize(5);
executor.setQueueCapacity(500);
executor.initialize();
return executor;
}
That new thread pool is working fine with that:
@Component
public class MessageJmsListener {
@Async
@EventListener
public void onApplicationEvent(CustomMessage messageJmsWrapper) {
log.info("Current thread: {}", Thread.currentThread().getName());
}
@Async
@EventListener
public void onApplicationEventSecond(SecondCustomMessage messageJmsWrapper) {
log.info("Second Listener thread: {} , Thread.currentThread().getName());
}
}
And I would like to achieve such an effect that for the first listener I give a separate bean (number of threads) and for the second. Is such a thing possible?
Thanks in advance! Best Regards