This topic describes the definition, model relationship, internal attributes, and behavior constraints of consumer groups in ApsaraMQ for RocketMQ. This topic also provides version compatibility information and usage notes for consumer groups.

Definition

A consumer group is a load balancing group that contains consumers that use the same consumption behaviors in ApsaraMQ for RocketMQ.

Unlike consumers that are running entities, consumer groups are logical resources. ApsaraMQ for RocketMQ initializes multiple consumers in a consumer group to achieve the scaling of consumption performance and high availability disaster recovery.

In a consumer group, consumers consume messages based on the consumption behaviors and load balancing policy that are defined in the group. The following section describes the consumption behaviors that are defined:

  • Subscription: ApsaraMQ for RocketMQ manages and traces subscriptions based on consumer groups. For more information, see Subscriptions.
  • Delivery order: The ApsaraMQ for RocketMQ broker delivers messages to consumers by using ordered delivery or concurrent delivery. You can configure the delivery method in the consumer group. For more information, see Ordered messages.
  • Consumption retry policy: the retry policy that is used when a consumer fails to consume a message. The policy includes the number of retries and the setting of dead-letter queues. For more information, see Consumption retries.

Model relationship

The following figure shows the position of consumer groups in the domain model of ApsaraMQ for RocketMQ.Consumer groups
  1. Producers produce and send messages to the ApsaraMQ for RocketMQ broker.
  2. The ApsaraMQ for RocketMQ broker stores the messages in the queue that is specified by the topic in the order in which the messages are received.
  3. Consumers obtain and consume messages from the ApsaraMQ for RocketMQ broker based on the specified subscriptions.

Internal attributes

Consumer group name
  • Definition: the name of a consumer group. Consumer group names are used to distinguish between consumer groups. Consumer group names are globally unique in a cluster.
  • Values: created and configured by users. For more information, see Limits on parameters.
Delivery order
  • Definition: the order in which ApsaraMQ for RocketMQ delivers messages to a consumer client.

    ApsaraMQ for RocketMQ supports ordered delivery and concurrent delivery based on different consumption scenarios. For more information, see Ordered messages.

  • Values: The default delivery method is concurrent delivery.
Consumption retry policy
  • Definition: the retry policy that is used when a consumer fails to consume a message. If a consumer fails to consume a message, the system re-delivers the failed message to the consumer for re-consumption based on the policy. For more information, see Consumption retries.
  • Values:
    A consumption retry policy contains the following items:
    • Maximum retries: the maximum number of times that a message can be re-delivered. If a message fails to be consumed and the maximum number of retries is exceeded, the message is delivered to the dead-letter queue or is discarded.
    • Retry interval: the interval between which the ApsaraMQ for RocketMQ broker re-delivers a failed message.

    For more information about the valid values and default values of maximum retries and retry intervals, see Limits on parameters.

  • Constraint: Retry interval is available only for push consumers.

Definition: the set of subscription relationships that are associated with the current consumer group. A subscription includes the topics to which the consumers in the group subscribe and the message filter rules that are used by the consumers. Consumers dynamically register subscriptions with consumer groups. The ApsaraMQ for RocketMQ broker persists subscriptions and matches the subscriptions with the consumption progress of messages. For more information, see Subscriptions.

Limits on consumption logic

In the domain model of ApsaraMQ for RocketMQ, consumers are managed in consumer groups. Consumers in the same consumer group share all messages that are delivered to the group. To ensure that messages are loaded and consumed as expected in a consumer group in ApsaraMQ for RocketMQ, the following consumption logic must be consistent for all consumers in the group:
  • Message delivery order
  • Consumption retry policy

Version compatibility

The message delivery order and consumption retry policy must be consistent for all consumers in a consumer group. The following items describe how the consistency is ensured in different Message Queue for Apache RocketMQ broker versions:
  • ApsaraMQ for RocketMQ 5.x brokers: Consumers obtain the message delivery order and consumption retry policy from the consumer group with which the consumers are associated. The consumption logic is the same for all consumers. You do not need to specify the message delivery order or consumption retry policy on the client.
  • ApsaraMQ for RocketMQ 3.x and 4.x brokers: The message delivery order and consumption retry policy are defined by API operations on your client. You must specify the message delivery order and consumption retry policy on the client to ensure that the consumption logic of all consumers in the consumer group is the same.

If you use an SDK of an earlier version to access a ApsaraMQ for RocketMQ 5.x broker, the consumption logic of consumers is determined by the configurations of API operations on the consumer client.

Usage notes

Create consumer groups based on your business requirements

In ApsaraMQ for RocketMQ, consumers and topics are in a many-to-many mapping relationship. We recommend that you take note of the following rules before you create consumer groups:
  • Consistent message delivery order: The message delivery order must be consistent for all consumers in a consumer group. The delivery method is either ordered delivery or concurrent delivery. We recommend that you do not use the same consumer group for different business scenarios.
  • Consistent business type: A consumer group corresponds to a topic. Different business domains have different requirements for message consumption, such as message filter rules and consumption retry policies. We recommend that you use different consumer groups in different business domains. We also recommend that you add up to 10 topics in a consumer group.

Avoid using automated mechanisms to manage consumer groups

In the ApsaraMQ for RocketMQ architecture, consumer groups are logical resources that are used to manage the status of consumers. Each consumer group is associated with various data, such as consumption status, accumulated messages, observable metrics, and monitoring data. We recommend that you strictly manage your consumer groups. Proceed with caution when you add, delete, modify, or query consumption groups.