Yes, there is a way to route messages to all queues using RabbitMQ headers exchange. You can use the special header "x-match" and set it to "all". This will match all headers in the message, and the message will be routed to all queues that have bindings with the headers that match.
Here's an example of how to create a headers exchange with "x-match" set to "all":
channel.exchangeDeclare("myHeadersExchange", "headers");
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("header1", "value1");
headers.put("header2", "value2");
AMQP.BasicProperties props = new AMQP.BasicProperties.Builder().headers(headers).build();
// create bindings
channel.queueBind("queue1", "myHeadersExchange", "", headers);
channel.queueBind("queue2", "myHeadersExchange", "", headers);
// publish message with x-match set to all
Map<String, Object> matchHeaders = new HashMap<String, Object>();
matchHeaders.put("x-match", "all");
matchHeaders.put("header1", "value1");
matchHeaders.put("header2", "value2");
channel.basicPublish("myHeadersExchange", "", new AMQP.BasicProperties.Builder()
.headers(matchHeaders).build(), "Hello, world!".getBytes());
With this configuration, the message will be routed to both "queue1" and "queue2" since both have bindings with header1=value1 and header2=value2.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-12-03 11:00:00 +0000
Seen: 11 times
Last updated: Oct 11 '22
What is the process of performing a GET request while using OAuth1 authentication?
How can I bring cipher files into Memgraph?
How can Response Headers be added to Blazor using .NET 6?
What is the required parameter for the token request when sending a token with value using Got?
Is it possible to alter the request headers of outgoing requests using a Chrome Extension?
In what way can actix middleware retrieve the response body and change the headers?
What does it mean when a CloudFront distribution sends back an Error 400?
How can I include header parameters in HttpClient for .NET Core?
How can I create a DataGrid in WPF with multiple levels of column headers?