All Products
Search
Document Center

ApsaraMQ for RabbitMQ:Ordered consumption

Last Updated:Mar 11, 2026

Ordered consumption guarantees that messages are delivered to consumers in the same order they were published. ApsaraMQ for RabbitMQ achieves this through Single Active Consumer mode and merge sort across distributed storage partitions, providing the same ordering semantics as open source RabbitMQ.

How it works

Ordered consumption requires two conditions: ordered storage and a single consumer.

Open source RabbitMQ

  • Single consumer: Open source RabbitMQ supports two modes: Single Active Consumer and Exclusive Consumer. The open source community recommends Single Active Consumer.

  • Ordered storage: Messages in the same queue are read from and written to a single node, which inherently preserves message order.

ApsaraMQ for RabbitMQ

  • Single consumer: ApsaraMQ for RabbitMQ uses the Single Active Consumer mode recommended by the open source community.

  • Ordered storage: ApsaraMQ for RabbitMQ uses a distributed architecture with decoupled storage and computing. Messages in a single queue are distributed across multiple partitions on multiple nodes. Compute nodes read messages from these storage partitions, perform a merge sort, and deliver them to the consumer in the correct order. This achieves the same ordered consumption semantics as open source RabbitMQ.

Merge sort in the distributed architecture

image

In Single Active Consumer mode, a queue maintains only one active connection. All other connections remain inactive. The compute node that owns the active connection pulls messages from all storage nodes, sorts them, and delivers them to the consumer.

Because the compute node sorts messages before delivery, it temporarily caches some messages. If the active connection fails over to a different compute node, these cached messages are re-added to the consumption queue for redelivery.

Benefits

Compared to open source RabbitMQ, the distributed architecture of ApsaraMQ for RabbitMQ provides:

  • High concurrency and scalability: Multiple partitions support high-concurrency writes and horizontal scaling.

  • High availability: Multiple consumers can connect to multiple compute nodes. If a consumer or compute node fails, the system can quickly fail over to a healthy node to maintain service continuity.

Enable ordered consumption

To enable ordered consumption, set the x-single-active-consumer argument to true when you create the queue.

Important

The server sorts messages before delivery, which can reduce the consumption rate. Evaluate whether your use case requires ordered consumption before enabling this feature.

Limitations

Ordered consumption is available only on the following instance editions:

  • Enterprise Edition

  • Platinum Edition

  • Serverless Edition