Spring Cloud Stream:从默认的 Rabbit MQ 交换和特定队列消费
Spring Cloud Stream: consume from default Rabbit MQ exchange and specific queue
是否可以通过 Spring Cloud Stream 从某些隐式绑定到默认 RabbitMQ 交换器的特定队列消费?
正如我在 BindingService.bindConsumer(...)
中的调试中看到的那样,如果我将 destination
指定为空字符串(yaml 中的''),bindingTargets
字符串数组为空,因此没有绑定消费者( binder.bindConsumer(...)
) 发生。
我可能的解决方法是指定一些随机目的地并将标志 queueNameGroupOnly
设置为 true
。
这是可能的,您只需指定您的 'input' and/or 'output' 绑定的目的地。
您可以通过以下属性执行此操作:
spring.cloud.stream.bindings.input.destination=<the name of the input queue>
spring.cloud.stream.bindings.input.group=<the name of the input group>
spring.cloud.stream.bindings.output.destination=<the name of the output exchange>
默认情况下,消费者使用路由键 #
.
将队列 destination.group
绑定到主题交换 destination
queueNameGroupOnly
When true, consume from a queue with a name equal to the group. Otherwise the queue name is destination.group
. This is useful, for example, when using Spring Cloud Stream to consume from an existing RabbitMQ queue.
Default: false.
要从仅绑定到默认交换器的现有队列中消费,您需要。
spring.cloud.stream.bindings.input.destination=<doesn't matter, can be omitted; defaults to input>
spring.cloud.stream.bindings.input.group=<the name of the queue>
spring.cloud.stream.rabbit.bindings.input.consumer.bind-queue=false
spring.cloud.stream.rabbit.bindings.input.consumer.queue-name-group-only=true
spring.cloud.stream.rabbit.bindings.input.consumer.declare-exchange=false
queueNameGroupOnly
是专门为此用例添加的。
是否可以通过 Spring Cloud Stream 从某些隐式绑定到默认 RabbitMQ 交换器的特定队列消费?
正如我在 BindingService.bindConsumer(...)
中的调试中看到的那样,如果我将 destination
指定为空字符串(yaml 中的''),bindingTargets
字符串数组为空,因此没有绑定消费者( binder.bindConsumer(...)
) 发生。
我可能的解决方法是指定一些随机目的地并将标志 queueNameGroupOnly
设置为 true
。
这是可能的,您只需指定您的 'input' and/or 'output' 绑定的目的地。 您可以通过以下属性执行此操作:
spring.cloud.stream.bindings.input.destination=<the name of the input queue>
spring.cloud.stream.bindings.input.group=<the name of the input group>
spring.cloud.stream.bindings.output.destination=<the name of the output exchange>
默认情况下,消费者使用路由键 #
.
destination.group
绑定到主题交换 destination
queueNameGroupOnly
When true, consume from a queue with a name equal to the group. Otherwise the queue name is
destination.group
. This is useful, for example, when using Spring Cloud Stream to consume from an existing RabbitMQ queue.Default: false.
要从仅绑定到默认交换器的现有队列中消费,您需要。
spring.cloud.stream.bindings.input.destination=<doesn't matter, can be omitted; defaults to input>
spring.cloud.stream.bindings.input.group=<the name of the queue>
spring.cloud.stream.rabbit.bindings.input.consumer.bind-queue=false
spring.cloud.stream.rabbit.bindings.input.consumer.queue-name-group-only=true
spring.cloud.stream.rabbit.bindings.input.consumer.declare-exchange=false
queueNameGroupOnly
是专门为此用例添加的。