【问题标题】:Rabbit spring cloud stream bind topics to single queueRabbit Spring Cloud Stream 将主题绑定到单个队列
【发布时间】:2017-10-05 11:51:22
【问题描述】:

是否可以将交换中的多个主题绑定到单个队列? 例如,我有生产者声明交换并发送三个主题 log.verboselog.infolog.error

我希望有两个消费者声明自己的队列并绑定到交换。 第一个消费者订阅前两个主题 log.verboselog.info,另一个消费者订阅所有主题。

是否可以为消费者 1 定义类似这样的配置?

spring.cloud.stream.bindings.input.destination=log
spring.cloud.stream.rabbit.bindings.input.consumer.bindingRoutingKey=log.info,log.verbose

【问题讨论】:

    标签: java spring rabbitmq spring-cloud-stream


    【解决方案1】:

    您目前无法通过属性配置来完成,但您可以自己添加第二个绑定,可以在管理 UI 上手动添加,也可以通过将 ExchangeQueueBinding @Beans 添加到应用程序.您不能简单地添加第二个 @Binding bean,因为当 RabbitAdmin 时(当应用程序首次启动且不存在队列时)队列还不存在。

    请参阅 Spring AMQP 参考手册中的Configuring the broker

    此技术不适用于匿名消费者(没有为input 指定...group 属性),因为队列名称未知。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-28
      • 1970-01-01
      • 2017-04-28
      • 1970-01-01
      • 1970-01-01
      • 2020-04-08
      • 2017-12-25
      相关资源
      最近更新 更多