我为应用程序上注册的每个队列创建了一个按需 ChannelAdapter、AsyncTaskExecutor 和一个 Channel。我注意到当maxPoolSize
AsyncTaskExecutor 的数量等于 1 时,消息没有被处理。这就是创建 AsyncTaskExecutor bean 的方式。
static void registerAsyncTaskExecutor(final Consumer consumer, final GenericApplicationContext registry) {
final TaskExecutor executor = consumer.getExecutor();
final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ThreadPoolTaskExecutor.class);
builder.addPropertyValue("corePoolSize", executor.getCorePoolSize());
builder.addPropertyValue("maxPoolSize", executor.getMaxPoolSize());
builder.addPropertyValue("threadNamePrefix", consumer.getName() + "-");
final String beanName = executor.getName();
final BeanDefinition beanDefinition = builder.getBeanDefinition();
registry.registerBeanDefinition(beanName, beanDefinition);
}
我注意到的另一件事是,当调用此方法时,java.util.concurrent.ThreadPoolExecutor#execute
此条件workerCountOf(c) < corePoolSize
始终为 false。完整的项目链接在这里https://github.com/LeoFuso/spring-integration-aws-demo