Multiple bindingRoutingKey's for a consumer with Spring Cloud Stream using RabbitMQ

假如想象 提交于 2019-12-11 12:04:57

问题


I'd like to configure an input channel in Spring Cloud Stream to be bound to the same exchange (destination) with multiple routing keys. I've managed to get this working with a single routing key like this:

spring:
  cloud:
    stream:
      rabbit:
        bindings:
          input1:
            consumer:
              bindingRoutingKey: key1.#
      bindings:
        input1:
          binder: rabbit
          group: group1
          destination: dest-group1

But I cannot seem to get it working for multiple keys. I've tried this:

spring:
  cloud:
    stream:
      rabbit:
        bindings:
          input1:
            consumer:
              bindingRoutingKey: key1.#,key2.#
      bindings:
        input1:
          binder: rabbit
          group: group1
          destination: dest-group1

But this doesn't seem to work.

I'm using Spring Boot 2.0.1 and Spring cloud dependencies are imported from:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>Finchley.RC1</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>

Does anyone know how to achieve this?


回答1:


It can't be done with properties; but you can declare the additional bindings as beans; see this answer.

There is also a third party "advanced" boot starter that allows you to add declarations in a yaml file. I haven't tried it, but it looks interesting.



来源:https://stackoverflow.com/questions/50587227/multiple-bindingroutingkeys-for-a-consumer-with-spring-cloud-stream-using-rabbi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!