如何使用注释配置 Spring Cloud AWS XML 配置?
我对更改默认任务执行器特别感兴趣。
我发现有SimpleMessageListenerContainerFactory
用于通过 Java 配置 AWS 消息传递。因此,更改默认taskExecutor
值只是覆盖此默认容器工厂 bean 的问题。像这样的东西:
@Bean
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory(AmazonSQSAsync amazonSqs) {
SimpleMessageListenerContainerFactory factory = new SimpleMessageListenerContainerFactory();
factory.setAmazonSqs(amazonSqs);
Executor executor = Executors.newFixedThreadPool(1);
ConcurrentTaskExecutor taskExecutor = new ConcurrentTaskExecutor(executor);
factory.setTaskExecutor(taskExecutor);
return factory;
}