0

Is it possible to achieve the following scenario using RabbitMQ topic exchange.

Lets say I have two queues:

Queue1: routing key MainRoute.Route1

Queue2: routing key MainRoute.Route2

When I publish my message with routing key:

MainRoute.Route1 -> Queue1

MainRoute.Route2 -> Queue2

MainRoute -> Queue1 and Queue2

Is it possible to achieve this without implementing some special filtering, routing process ?

If not can you please advise on a possible solution for the problem.

Thank you.

schizofreindly
  • 177
  • 2
  • 13

1 Answers1

0

This can be done with a direct or a topic exchange, and would require 4 bindings in your exchange.

Assuming an exchange named "MainEx" as an example, the routing keys would be set up like this:

| exchange | binding          | queue  |
| -------- | ---------------- | ------ |
| MainEx   | MainRoute.Route1 | Queue1 |
| MainEx   | MainRoute.Route2 | Queue2 |
| MainEx   | MainRoute        | Queue1 |
| MainEx   | MainRoute        | Queue2 |

With a topic exchange, you could send multiple messages to a single queue by using flags. For example, binding "MainRoute.#" to "Queue3" would send all MainRoute messages to Queue3.

But, there is no way to do the opposite with a single binding. You need to create multiple bindings to do what you want.

Derick Bailey
  • 72,004
  • 22
  • 206
  • 219
  • Yes it's actually what I did. Is there any examples of advance topology routing examples. I thought that enterprise integration patterns will be a good reference, however, it's very shallow book. – schizofreindly Aug 25 '15 at 20:46
  • I don't know of anything that covers advanced routing configuration... but i'm honestly not sure there is a lot of advanced routing capabilities. i wrote a book that covers more an intro level for people that are still working to understand when to use each type of exchange, though: https://leanpub.com/rabbitmq-structures-and-layout don't know if it would help in your case, but it might. – Derick Bailey Aug 25 '15 at 21:20