[rabbitmq-discuss] Preserving Order Across Multiple Consumers on a Single Queue

Emile Joubert emile at rabbitmq.com
Mon Jul 2 13:53:28 BST 2012


Hi,

On 01/07/12 17:42, Charles Law wrote:
> Can we set this up fairly easily with RabbitMQ?  Or use a different
> setup to accomplish the same goal?

Take a look at the ordering guarantees made by the broker:
http://www.rabbitmq.com/semantics.html#ordering

If you require operations on each database to be applied in order then
you should use a queue per database.

If you allow more than one consumer to subscribe to a queue then they
may attempt to perform CRUD operations simultaneously or even out of
order, so avoid more than one consumer per queue. The "exclusive" option
can enforce this constraint:

http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.consume.exclusive

I don't see how you can spread the load across multiple consumers for
operations to a single database that have to be performed in order.
There may be some combinations of operations that can be parallelised,
such as "add row x" and "add row y" where the order does not matter, but
it would be challenging to exploit that potential. Making use of QoS
prefetch-count will probably be useful in that scenario:

http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.prefetch-count



-Emile




More information about the rabbitmq-discuss mailing list