Search code examples
eventsrabbitmqcqrsrabbitmq-exchange

How to organize exchanges and queues in rabbitmq to use with async CQRS buses


I'm scaffolding my backend application and I want to use CQRS and rabbitmq with it (I'm pretty new to rabbitmq). For that, I have specified different vhosts for my prod and dev environments, but I'm not sure how to use exchanges and queues for command, events and query buses.

Should I use just one exchange, named for example CQRS and three different queues for commands, queries and events?

Or maybe should I use three different exchanges (named query_bus, command_bus and event_bus) and inside each one map one queue to every possible command query and event using routing keys?

Thanks!


Solution

  • You should have separate queues for different content (commands, queries...).

    Because then its easier to see if the command or query side is lagging/slow by examining the length of each queue. The queue length gives you nice charts for your dashboard.