你需要再介绍一个 RabbitListenerContainerFactory 具有适当配置的bean,并使用其名称来自第二个 @RabbitListener :
RabbitListenerContainerFactory
@RabbitListener
/** * The bean name of the {@link org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory} * to use to create the message listener container responsible to serve this endpoint. * <p>If not specified, the default container factory is used, if any. * @return the {@link org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory} * bean name. */ String containerFactory() default "";
通过这种方式,您将区分Spring Boot提供的默认值,并为另一个用例提供自己的自定义。
查看文档中的更多信息: https://docs.spring.io/spring-amqp/docs/2.1.4.RELEASE/reference/#async-annotation-driven