如何使用注释配置Spring Cloud AWS消息传递?

时间:2018-05-17 09:18:38

标签: java spring spring-cloud-aws

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

我对更改默认的taskExecutor特别感兴趣。

1 个答案:

答案 0 :(得分:0)

我发现有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;
}