Reputation: 40510
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?
Upvotes: 4
Views: 2454
Reputation: 110
This can be done now by adding a property:
spring.cloud.stream.rabbit.bindings.<channel-name>.consumer.binding-routing-key-delimiter=,
Then you can comma separate the routing keys:
spring.cloud.stream.rabbit.bindings.<channel-name>.consumer.binding-routing-key=key1,key2,key3
Upvotes: 5
Reputation: 174554
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.
Upvotes: 2