Search code examples
routesrabbitmqamqp

RabbitMQ message to multiple queues distribution equility


I'm using RabbitMQ to distribute messages from server to multiple clients. Each client has its own queue. There is one message published by the server to an exchange and there are multiple bindings which cause the distribution to multiple queues.

See the following diagram. A message is published to "Common Exchange" from which there are bindings to user specific exchanges (e.g. "User 1 Exchange") and finally there is last binding from user specific exchange to the user queue (e.g. "User 1 queue"). Message routing

Now my problem is that I don't want some client to have an advantage of getting a message earlier than the others. (e.g. User 1 will have the message available always earlier than User 2)

My question is: Is the message available in the queues in deterministic order?

EDIT: I know that the differences are likely very small (if any). Yet I need to know - clients are asking. The server produces quite a lot of large messages (thousands per second) during peaks. Also because of reliability we have HA policy on almost all queues which might also take some overhead. So I think if there are some differences during peaks they would eventually show up.

Thank you

Frank


Solution

  • I asked the very same question on RabbitMQ forum and here's the answer:

    Message routing will first compile a list of exchanges for routing according to the bindings available, then iterate over them. It works the same for queues.

    Then channel that performs routing will simply iterate over the queues and publish a message to them. This happens asynchronously, so a message for the first queue on the list can reach the queue earlier or later than, say, the last queue on the list.

    Consumer delivery with N queues also will happen asynchronously and (if enough cores are available to the runtime) in parallel.

    So to answer the question: there is no predictable order in which one particular message is available on queues.