2

如何使用注释配置 Spring Cloud AWS XML 配置?

我对更改默认任务执行器特别感兴趣。

4

1 回答 1

3

我发现有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;
}
于 2018-05-17T09:36:12.463 回答