All Products
Search
Document Center

ApsaraMQ for RocketMQ:Subscriptions

Last Updated:Mar 11, 2026

A subscription is a set of filter rules and status configurations that a consumer group uses to receive and process messages in ApsaraMQ for RocketMQ.

Consumer groups dynamically register subscriptions with the server. During message delivery, the server matches messages against the subscription's filter rules and tracks consumption progress.

A subscription controls:

  • Message scope: Which messages within a topic are delivered to the consumer group.

  • Consumption progress: The server-side record of which messages have been consumed. ApsaraMQ for RocketMQ persists consumption progress by default. If a consumer goes offline and reconnects, it resumes from where it left off.

Topic and consumer group relationships

One topic, multiple consumer groups

ApsaraMQ for RocketMQ supports one-to-many subscriptions. Multiple consumer groups can independently subscribe to the same topic, and each group can consume all or a subset of the messages.

One topic subscribed by multiple consumer groups

One consumer group, multiple topics

A single consumer group can subscribe to multiple topics. Each topic subscription is independent and can have its own filter rules.

For example, consumer group Group A subscribes to both Topic A and Topic B. The two subscriptions are separate -- changing one does not affect the other.

One consumer group subscribing to multiple topics

Consumption modes

The consumption mode determines how messages are distributed to consumers within a group.

ModeApplies toBehavior
CLUSTERINGStandard (non-Lite) topicsEach message is delivered to one consumer in the group based on load balancing.
LITE_SELECTIVELite topics onlyEach consumer in the group can subscribe to a different set of Lite topics.

Message filtering

Message filtering is available in CLUSTERING mode. Use filter rules to narrow the messages delivered to a consumer group beyond topic-level subscriptions.

Filter types

TypeDescription
TAG filteringMatches messages based on the full text of tag strings.
SQL92 filteringMatches message attributes based on SQL92 expressions.

Filter expressions

Filter expressions define the matching criteria for each filter type. For syntax details, see Filter expression syntax.

Subscription constraints by mode

CLUSTERING mode: keep subscriptions consistent across the group

In CLUSTERING mode, all consumers in the same consumer group must use identical subscription relationships and consumption logic. Mismatched subscriptions cause consumption conflicts, which can lead to abnormal consumption for some messages.

Correct -- both consumers subscribe to the same topic with the same tag:

// Consumer c1
Consumer c1 = ConsumerBuilder.build(groupA);
c1.subscribe(topicA,"TagA");
// Consumer c2
Consumer c2 = ConsumerBuilder.build(groupA);
c2.subscribe(topicA,"TagA");

Incorrect -- consumers in the same group subscribe to the same topic with different tags:

// Consumer c1
Consumer c1 = ConsumerBuilder.build(groupA);
c1.subscribe(topicA,"TagA");
// Consumer c2
Consumer c2 = ConsumerBuilder.build(groupA);
c2.subscribe(topicA,"TagB");

LITE_SELECTIVE mode: flexible per-consumer subscriptions

In LITE_SELECTIVE mode, consumers within the same group can subscribe to different sets of Lite topics. For example, Consumer 1 subscribes to LiteTopic1 and LiteTopic2, while Consumer 2 subscribes to LiteTopic3 and LiteTopic4.

Lite topics can be added to or removed from each consumer's subscription set in real time.

LITE_SELECTIVE mode -- different consumers subscribe to different Lite topics