Spring cloud stream: As a producer with requiredGroups defined can i specify a routingKey for the queue that will be created?

huangapple go评论49阅读模式
英文:

Spring cloud stream: As a producer with requiredGroups defined can i specify a routingKey for the queue that will be created?

问题

我在文档中找不到关于我的问题的任何信息。如果有的话,而我漏掉了,请指出给我。

我有一个使用Spring Cloud Stream的RabbitMQ消息生产者服务,我的配置如下:

spring:
  cloud:
    stream:
      bindings:
        outputSink-out-0:
          destination: foo
          producer:
            requiredGroups: bar

上述配置在RabbitMQ中创建了名为foo的交换机以及一个带有路由键#bar队列。我的问题是,如何配置bar队列的特定路由键,例如test.#

英文:

I could not find anything in the documentation regarding my issue. If it is there and I missed it, please point it out to me.

I have a RabbitMQ message producer service using Spring Cloud Stream, and my configuration is as follows:

spring:
  cloud:
    stream:
      bindings:
        outputSink-out-0:
          destination: foo
          producer:
            requiredGroups: bar

The above configuration creates my foo exchange in RabbitMQ and a bar queue with a routing key of #. My question is, how can I configure a specific routing key, such as test.#, for the bar queue?

答案1

得分: 1

请查看文档:https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream-binder-rabbit.html#rabbit-prod-props

spring.cloud.stream.rabbit.bindings.outputSink-out-0.producer.binding-routing-key=...

>bindingRoutingKey

>用于将队列与交换机绑定的路由键(如果bindQueue为true)。可以是多个键 - 请参见bindingRoutingKeyDelimiter。对于分区目标,将-n附加到每个键。仅在提供了requiredGroups时才适用,而且仅适用于这些组。

>默认值:#。

英文:

See the documentation: https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream-binder-rabbit.html#rabbit-prod-props

spring.cloud.stream.rabbit.bindings.outputSink-out-0.producer.binding-routing-key=...

>bindingRoutingKey

>The routing key with which to bind the queue to the exchange (if bindQueue is true). Can be multiple keys - see bindingRoutingKeyDelimiter. For partitioned destinations, -n is appended to each key. Only applies if requiredGroups are provided and then only to those groups.

>Default: #.

huangapple
  • 本文由 发表于 2023年6月16日 15:06:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76487711.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定