每一个RabbitListenerContainerFactory都有一个@RabbitListener。除非注释中另有规定,否则将使用默认值。
还可以使用rabbitListenerAnnotationBeanPostProcessor.setContainerFactoryBeanName()更改默认设置。
我正在寻找一种方法,为应用程序中的每个 ContainerFactory 设置一个 @RabbitListener (如果已经通过原始注释设置,甚至覆盖)( ContainerFactory将根据要侦听的队列名称进行设置)。
额外的问题是:如何设置(在这种情况下) ContainerFactory bean本身,而不是设置bean的名称(如上面的setContainerFactoryBeanName )。
发布于 2022-06-22 13:59:46
只需在@RabbitListener注释上设置工厂bean名称:
/**
* 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. If a SpEL
* expression is provided ({@code #{...}}), the expression can either evaluate to a
* container factory instance or a bean name.
* @return the
* {@link org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory}
* bean name.
*/
String containerFactory() default "";https://stackoverflow.com/questions/72713309
复制相似问题