不确定您错过了什么,但是针对这种用例进行了准确的测试:
@EnableSqs
@Configuration
public static class ConfigurationWithCustomContainerFactory {
@Bean
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory() {
SimpleMessageListenerContainerFactory factory = new SimpleMessageListenerContainerFactory();
factory.setAmazonSqs(amazonSQS());
...
return factory;
}
@Bean
public AmazonSQSAsync amazonSQS() {
return AMAZON_SQS;
}
}
因此,@EnaqbleSqs
仍在此处,SqsConfiguration
并且@Autowired
与您的自定义项相同SimpleMessageListenerContainerFactory
@Bean
。