All Products
Search
Document Center

ApsaraMQ for RocketMQ:LiteTopic model

Last Updated:Oct 27, 2025

This topic describes the definition, model, internal properties, behavioral constraints, version compatibility, and usage recommendations for LiteTopics in ApsaraMQ for RocketMQ.

Prerequisites

  • LiteTopics are supported only by non-Serverless instances (subscription and pay-as-you-go) and dedicated instances in the Serverless series.

  • Submit a ticket to be added to the whitelist for the LiteTopic model feature. When you submit the ticket, provide the user ID (UID) of the Alibaba Cloud account that was used to purchase the instance and the region where the instance resides.

Definition

A LiteTopic is a secondary container for message transmission and storage in ApsaraMQ for RocketMQ. It is used to differentiate messages of different child classes, such as sessions or tasks, within the same business logic.

The main functions of LiteTopics are as follows:

  • Implement exclusive consumption and provide secondary data isolation

You can manage data from different child classes in separate LiteTopics to achieve finer-grained storage and subscription isolation.

  • Define data identities and permissions

Building on topic-based identity and permission management, you can use LiteTopics to further refine user identities and permissions.

Model relationship

In the domain model of ApsaraMQ for RocketMQ, a LiteTopic fits into the data flow as follows:

image.png

  • A topic is the top-level container for message transmission and storage in ApsaraMQ for RocketMQ. If the topic type is Lite, you can create LiteTopics under the topic. The combination of the topic and the LiteTopic uniquely identifies the message storage container.

  • If the topic type is Lite, each storage container consists of one queue by default.

Internal properties

LiteTopic name

  • Definition: The name of a LiteTopic. It identifies the LiteTopic and must be unique within its parent topic.

  • Value: If the topic type is Lite and you call setLiteTopic for a message, the system automatically creates the corresponding LiteTopic if it does not exist.

  • Constraints: For more information, see Parameter limits.

Expiration time

  • Definition: The expiration time of a LiteTopic. If a LiteTopic does not receive any new messages for a period that exceeds its expiration time, the LiteTopic is automatically deleted. When a LiteTopic is deleted, its resources are released, and the total count of LiteTopics is decremented by one.

  • Value: When you create a topic of the Lite type, you can set the expiration time.

  • Constraints: For more information, see Parameter limits.

Version compatibility

  • Server version: 5.0-rmq-20251024-1 or later

  • Client version: RocketMQ gRPC 5.1.0 or later

Differences between Lite topics and normal topics

Scenario

Comparison item

Lite topic

Normal topic

Message storage

Primary topic

Same. Topic resources must be created in advance for both types.

Secondary topic

You can create millions of secondary topic resources (LiteTopics) under a topic. These secondary resources have many new features.

No secondary topic resources.

Automated lifecycle management

The lifecycle of secondary topics (LiteTopics) can be managed automatically:

  • Automatic creation: If a LiteTopic does not exist when a message is sent or subscribed to, the resource is automatically created.

  • Automatic deletion: If you set an expiration time, the LiteTopic is automatically deleted after a period of inactivity.

N/A

Ordering

Each LiteTopic has only one queue, which ensures that messages are stored in order within that queue.

  • Each LiteTopic

Multiple queues are created. Only partitioned ordered topics ensure order.

Maximum concurrent TPS for sending and receiving

Because there is only one queue, the maximum transactions per second (TPS) for each LiteTopic is limited.

However, you can create millions of LiteTopics under a topic, so the total maximum TPS can increase as you add more LiteTopics.

The TPS of a topic can be scaled out by increasing the number of queues and cluster nodes.

Message consumption

Subscription relationship consistency

Can be inconsistent.

Within the same group, each consumer can subscribe to a different set of LiteTopics. The constraint on the group is relaxed.

Must be consistent.

Within the same group, each consumer must have the same subscription relationship to share messages under the target topic.

Ordering

Ordered consumption. Messages in a LiteTopic can be processed by only one consumer thread.

You can choose concurrent consumption or ordered consumption.

Dynamic subscription

Each consumer can dynamically add or remove subscriptions to a specific LiteTopic.

N/A

Number of LiteTopics a single consumer can subscribe to

Each consumer can subscribe to thousands of LiteTopics.

N/A

Observability

Metrics data

Provides message accumulation metrics.

Does not provide message processing latency metrics.

Provides message accumulation metrics.

Provides message processing latency metrics.

Message trace

Same

Common LiteTopic scenarios

Scenario 1: Asynchronous communication for multi-agent systems to resolve blocking from long-running calls

As AI scenarios become more complex, single agents are often limited in complex situations. They lack a specialized division of labor, struggle to integrate multiple domains, and cannot make dynamic collaborative decisions. As a result, single-agent applications and workflows are gradually being replaced by multi-agent systems. However, AI tasks are often long-running. Synchronous calls can block the caller's thread, which causes scalability issues in large-scale collaboration.

image.png

As shown in the preceding figure, the workflow of a multi-agent system is as follows: A supervisor agent splits a request and assigns it to two sub-agents. The two sub-agents handle their respective domain-specific problems and return the results to the supervisor agent. The supervisor agent aggregates the results and returns them to the web client. The process of using the ApsaraMQ for RocketMQ asynchronous communication solution is as follows:

  1. In the request flow:

    1. Create a request topic for each sub-agent to serve as a buffer queue for tasks. You can use a priority topic to process high-priority tasks first.

    2. The supervisor agent sends the split task information to the corresponding request topics.

  2. In the response flow:

    1. The supervisor agent creates a LiteTopic for responses and subscribes to it.

    2. The sub-agents process the tasks and send the response for each task to a LiteTopic under the response topic. You can name the LiteTopic after the task ID to create a dedicated LiteTopic for each task.

    3. The supervisor agent subscribes to the LiteTopics to retrieve the results in real time and then pushes them to the web client using the HTTP Server-Sent Events (SSE) protocol.

Scenario 2: Distributed session state management to solve session management challenges in AI applications

The interaction model of AI applications is unique. It involves long-running, multi-turn sessions that rely heavily on computationally expensive resources. When an application depends on persistent connections such as SSE, any connection interruption, such as a gateway restart, connection timeout, or network instability, not only causes the loss of the current session context but also invalidates ongoing AI tasks. This wastes valuable computing power.

image.png

As shown in the preceding figure, the response flow is the same as in Scenario 1. A LiteTopic is used to send real-time notifications of results. Here, each LiteTopic can be named using the session ID, for example, chatbot/{sessionID}. This way, session results are passed sequentially as messages in this topic. The solution to maintain session continuity after a persistent connection is re-established is as follows:

  1. Web client 2 establishes a persistent connection with application service node 1 and creates session 2.

  2. Application service node 1 subscribes to the LiteTopic [chat/SessionID2].

  3. The large model task scheduling component sends the results to the LiteTopic [chat/SessionID2] based on the SessionID information in the request.

  4. Due to a network issue or another exception, the WebSocket connection automatically reconnects to application service node 2.

  5. Application service node 1 unsubscribes from the LiteTopic [chat/SessionID2], and application service node 2 subscribes to the LiteTopic [chat/SessionID2].

  6. The LiteTopic [chat/SessionID2] continues to push subsequent unconsumed messages to application service node 2 from where the previous consumption left off. This ensures session state and data continuity.

Sample code

For a complete example, see the sample code in RocketMQ 5.x gRPC SDK.

Send messages

Producer producer = provider.newProducerBuilder()
    .setTopics(topic)
    .setClientConfiguration(clientConfiguration)
    .build();

final Message message = provider.newMessageBuilder()
    .setTopic(topic)
    // Set the message key. You can use the key to accurately find a specific message.
    .setKeys("messageKey")
    // Set the LiteTopic.
    .setLiteTopic("lite-topic-1")
    // Message body.
    .setBody("messageBody".getBytes())
    .build();

try {
    final SendReceipt sendReceipt = producer.send(message);
    log.info("Send message successfully, messageId={}", sendReceipt.getMessageId());
} catch (LiteTopicQuotaExceededException e) {
    // The LiteTopic quota is exceeded. Evaluate and increase the quota.
    log.error("Lite topic quota exceeded", e);
} catch (Throwable t) {
    log.error("Failed to send message", t);
}

Consume messages

You must use the LitePushConsumer class:

// Initialize LitePushConsumer. You must bind the consumer group, target topic, communication parameters, and more.
LitePushConsumer litePushConsumer = provider.newLitePushConsumerBuilder()
    .setClientConfiguration(clientConfiguration)
    // The topic bound when the consumer group was created in the console.
    .bindTopic(topicName)
    // Set the consumer group.
    .setConsumerGroup(consumerGroup)
    .setMessageListener(messageView -> {
        // Process the message and return the consumption result.
        LOGGER.info("Consume message={}", messageView);
        return ConsumeResult.SUCCESS;
    })
    .build();

try {
    // Subscribe to a collection of LiteTopics of interest.
    litePushConsumer.subscribeLite("lite-topic-1");
    litePushConsumer.subscribeLite("lite-topic-2");
    litePushConsumer.subscribeLite("lite-topic-3");
} catch (LiteSubscriptionQuotaExceededException e) {
    // The LiteTopic quota is exceeded. Evaluate and increase the quota.
    log.error("Lite subscription quota exceeded", e);
} catch (Throwable t) {
    log.error("Failed to subscribe lite topic", t);
}

// After business processing is complete, promptly unsubscribe from LiteTopics that are no longer in use.
litePushConsumer.unsubscribeLite("lite-topic-3");

// Get the set of currently subscribed LiteTopics.
Set<String> liteTopicSet = litePushConsumer.getLiteTopicSet();

Dynamically modify subscription relationships

/**
 * Dynamically add a subscription relationship.
 * The subscribeLite() method initiates a network request and performs quota verification, so the call may fail.
 * Make sure to check the result of this call to ensure that the subscription is successfully added.
 * Possible failure scenarios include the following:
 * 1. A network request error occurs. You can retry the operation.
 * 2. Quota verification fails, and a LiteSubscriptionQuotaExceededException is thrown.
 * Evaluate whether the quota meets your needs and promptly use unsubscribeLite() to unsubscribe from topics that are no longer in use to release resources.
 */

litePushConsumer.subscribeLite("lite-topic-1");

// Dynamically delete a subscription relationship.
litePushConsumer.unsubscribeLite("lite-topic-1");

Limits

  1. A single consumer can subscribe to a maximum of 2,000 LiteTopics. You can submit a ticket to adjust this limit.

  2. The maximum consumption throughput for a single LiteTopic is 200 transactions per second (TPS).

  3. To ensure service stability, a limit applies to the number of LiteTopics that can be created or subscribed to within a single instance. For specific quota details, see the following tables. You can submit a ticket to adjust the quotas.

    1. Number of LiteTopics that can be created

      • Definition: The total number of active LiteTopics in a single instance.

      • Trigger and impact: When this limit is reached, if a client tries to send a message to a non-existent LiteTopic, which would trigger automatic creation, the system cannot create the LiteTopic and the message fails to send.

    2. Number of LiteTopic subscriptions

      • Definition: The total number of valid subscription relationships established between all online consumer clients and LiteTopics within an instance. This value changes dynamically.

      • Impact: When this limit is reached, any attempt by a consumer client to subscribe to a new LiteTopic will fail, and a new subscription relationship cannot be established.

      • Special rule: Even if a LiteTopic is deleted from the system, an active subscription to it from a consumer client is still counted toward the total number of subscriptions until the consumer unsubscribes.

Serverless series instances

Deployment architecture

Capacity model

Specifications

Maximum number of LiteTopics that can be created or subscribed to

Dedicated

Reserved + Elastic

5,000

300,000

10,000

600,000

15,000

720,000

[20,000, 50,000]

1,000,000

(50,000, 100,000]

1,500,000

(100,000, 200,000]

2,400,000

(200,000, 300,000]

4,700,000

(300,000, 500,000]

6,300,000

(500,000, 1,000,000]

11,600,000

Non-Serverless series (subscription and pay-as-you-go) instances

Standard Edition

Instance type

Base TPS limit for message sending and receiving (times/second)

Maximum number of LiteTopics that can be created or subscribed to

rmq.s2.2xlarge

2,000

150,000

rmq.s2.4xlarge

4,000

250,000

rmq.s2.6xlarge

6,000

300,000

Professional Edition

Instance type

Base TPS limit for message sending and receiving (times/second)

Maximum number of LiteTopics that can be created or subscribed to

rmq.p2.2xlarge

2,000

150,000

rmq.p2.4xlarge

4,000

250,000

rmq.p2.6xlarge

6,000

300,000

rmq.p2.10xlarge

10,000

600,000

rmq.p2.20xlarge

20,000

800,000

rmq.p2.30xlarge

30,000

1,000,000

rmq.p2.40xlarge

40,000

1.2 million

rmq.p2.50xlarge

50,000

1.4 million

rmq.p2.100xlarge

100,000

2,200,000

rmq.p2.120xlarge

120,000

2,700,000

rmq.p2.150xlarge

150,000

3,300,000

rmq.p2.200xlarge

200,000

4,500,000

Platinum Edition

Instance type

Base TPS limit for message sending and receiving (times/second)

Maximum number of LiteTopics that can be created or subscribed to

rmq.u2.10xlarge

10,000

600,000

rmq.u2.20xlarge

20,000

800,000

rmq.u2.30xlarge

30,000

1,000,000

rmq.u2.40xlarge

40,000

1,200,000

rmq.u2.50xlarge

50,000

1,400,000

rmq.u2.60xlarge

60,000

1,600,000

rmq.u2.70xlarge

70,000

1,700,000

rmq.u2.80xlarge

80,000

1,800,000

rmq.u2.90xlarge

90,000

2,000,000

rmq.u2.100xlarge

100,000

2,200,000

rmq.u2.120xlarge

120,000

2,700,000

rmq.u2.150xlarge

150,000

3,300,000

rmq.u2.200xlarge

200,000

4,500,000

rmq.u2.250xlarge

250,000

5,600,000

rmq.u2.300xlarge

300,000

6,300,000

rmq.u2.350xlarge

350,000

7,500,000

rmq.u2.400xlarge

400,000

9,300,000

rmq.u2.450xlarge

450,000

10,400,000

rmq.u2.500xlarge

500,000

11,600,000

rmq.u2.550xlarge

550,000

12,800,000

rmq.u2.600xlarge

600,000

14,000,000

rmq.u2.1000xlarge

1,000,000

23,200,000