wat*_*ery 3 java spring spring-amqp spring-boot
在问题How to set the Consumer-tag value in spring-amqp 中,有人询问如何在使用 Spring Amqp 时更改消费者标签,答案建议提供ConsumerTagStrategy.
我正在使用 Spring Boot 2.0.5,我试图弄清楚是否可以进行相同的自定义,尽管我找不到任何相关的配置属性,也没有提供ConsumerTagStrategy似乎有效的类型的 bean。
我该怎么办?
覆盖 boot 的容器工厂 bean 声明并将其添加到那里。
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
SimpleRabbitListenerContainerFactoryConfigurer configurer,
ConnectionFactory connectionFactory) {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
configurer.configure(factory, connectionFactory);
factory.setConsumerTagStrategy(q -> "myConsumerFor." + q);
return factory;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1458 次 |
| 最近记录: |