All Products
Search
Document Center

ApsaraMQ for RabbitMQ:Ordered consumption

Last Updated:Dec 18, 2025

This topic describes the working mechanism, configuration method, and usage limits of the ordered consumption feature of ApsaraMQ for RabbitMQ. It also describes the differences between the ordered consumption features of ApsaraMQ for RabbitMQ and open source RabbitMQ.

How it works

The following conditions must be met at the same time to use the ordered consumption feature of RabbitMQ: The single active consumer mode is used and messages are stored in order.

Implement ordered consumption in open source RabbitMQ

  • Single active consumer mode: Open source RabbitMQ supports the single active consumer mode and the exclusive consumer mode. The open source community recommends the single active consumer mode. For more information, see Single Active Consumer.

  • Ordered storage: In open source RabbitMQ, messages in the same queue are processed only on one node. Therefore, messages are stored in open source RabbitMQ in specific order.

Implement ordered consumption in ApsaraMQ for RabbitMQ

  • Single active consumer mode: ApsaraMQ for RabbitMQ supports the single active consumer mode recommended by the open source community.

  • Ordered storage: ApsaraMQ for RabbitMQ uses a distributed architecture in which storage and computing are decoupled. Messages in a queue are distributed in multiple partitions on multiple nodes. To implement ordered consumption in ApsaraMQ for RabbitMQ, compute nodes read messages in partitions from storage nodes, sort the messages in order, and then deliver the messages to the consumer.

Implementation of ordered consumption in a distributed architecture with decoupled storage and computing

image

As shown in the preceding figure, a queue in Single Active Consumer mode has only one active connection. All other connections are inactive. The compute node that manages the active connection pulls messages from all storage nodes, sorts the messages, and then delivers them to the consumer.

In this case, the compute node temporarily caches some messages because messages are sorted in the compute node. When the active consumer attempts to obtain messages from multiple compute nodes, the cached messages are requeued.

Benefits of ApsaraMQ for RabbitMQ

  • High concurrency and scalability: ApsaraMQ for RabbitMQ ensures that data is written with high concurrency in multi-partition systems. ApsaraMQ for RabbitMQ also provides excellent scale-out capabilities.

  • High availability: ApsaraMQ for RabbitMQ allows multiple consumers to connect to multiple compute nodes for high availability. If one of the consumers or compute nodes fails, the system can quickly switch services to other nodes.

Configuration method

To enable ordered consumption, you can configure the queue to use the Single Active Consumer mode. When you create the queue, set the x-single-active-consumer parameter to true.

Important

After you enable the single active consumer mode, the broker delivers messages to the consumer after sorting the messages. This may reduce the message consumption rate. We recommend that you evaluate whether the single active consumer mode is required before you enable the mode.