Reputation: 2029
How can I bind a Rabbit Listener to multiple routing keys on the same exchange? I am using spring-rabbit 1.7.9.RELEASE.
This is what I have so far:
@RabbitListener(bindings = {
@QueueBinding(value =
@Queue(value = "foo"), exchange = @Exchange("ex1"), key="foo")
})
public void listen(String in) {
// Do something
}
Upvotes: 0
Views: 1752
Reputation: 121560
The key
attribute of that @QueueBinding
annotation is like this:
/**
* @return the routing key or pattern for the binding.
* Multiple elements will result in multiple bindings.
*/
String[] key() default {};
So, you just need to have a list of those routing keys:
@QueueBinding(value =
@Queue(value = "foo"), exchange = @Exchange("ex1"), key={"foo", "bar", "baz"})
Or pattern as you see from those JavaDocs.
Upvotes: 1