All Products
Search
Document Center

ApsaraMQ for RocketMQ:LiteTopic model

Last Updated:Mar 11, 2026

LiteTopics are lightweight, ephemeral sub-channels within a single ApsaraMQ for RocketMQ topic. You can create millions of fine-grained message channels -- one per session, task, or user -- without the resource overhead of separate topics. Each LiteTopic is an auto-managed secondary container inside a single parent topic, with its own ordered queue, lifecycle, and subscription scope.

Prerequisites

Before you begin, make sure that you have:

  • A non-serverless instance (subscription or pay-as-you-go) or a dedicated serverless instance

  • For new instances: On the purchase page, a product capability tag with the tag key set to version_capability and the tag value set to lite-topic

    Tag configuration on the purchase page

  • For existing instances: An upgraded instance version that supports LiteTopics. Submit a ticket to request the upgrade. Include the instance ID and region in your request.

You can also submit a ticket to request a free consultation for LiteTopic-based solutions.

Key concepts

What is a LiteTopic

A LiteTopic is a secondary container for message transmission and storage within a parent topic. It groups messages of different child classes -- such as individual sessions, tasks, or users -- under the same business logic.

LiteTopics serve two purposes:

  • Exclusive consumption and data fencing: Isolate data from different child classes into separate LiteTopics for finer-grained storage and subscription boundaries.

  • Identity and permissions: Control access at a granularity finer than the topic level by assigning identities and permissions to individual LiteTopics.

How LiteTopics fit into the domain model

LiteTopic domain model

A topic is the top-level container for message transmission and storage in ApsaraMQ for RocketMQ. If a topic is of the Lite type, LiteTopics can be created within it. The combination of a topic and a LiteTopic uniquely identifies a message storage container.

Each LiteTopic contains one queue by default, and messages within that queue are stored and consumed in order.

LiteTopic properties

Name

  • Must be globally unique within the parent topic.

  • Auto-created on first use: if setLiteTopic is called on a message and the specified LiteTopic does not exist, the system creates it automatically.

  • For naming constraints, see Parameter limits.

Time-to-live (TTL)

  • If a LiteTopic receives no messages for longer than its TTL, the system deletes it automatically. Deletion releases the quota count.

  • Set the TTL through the expiration value when you create the Lite-type topic.

  • For TTL constraints, see Parameter limits.

Version compatibility

ComponentMinimum version
Server5.0-rmq-20251024-1 or later
Client (gRPC SDK)RocketMQ gRPC 5.1.0 or later

LiteTopics vs. normal topics

Important

Switching a topic to Lite type changes its behavior. Each LiteTopic has only one queue by default, which limits per-channel TPS but enables ordered consumption and fine-grained subscription control. Evaluate this tradeoff before adopting Lite-type topics.

DimensionLite topicNormal topic
Primary topicBoth require you to create topic resources in advance.Same as Lite.
Secondary channelsSupports millions of LiteTopics under a single parent topic, each with auto-managed lifecycle.No secondary channel support.
Lifecycle managementAutomatic creation on first send or subscribe. Automatic deletion after the configured TTL expires.Manual creation and deletion only.
OrderingEach LiteTopic has one queue by default. Messages are stored in order.Multiple queues. Only partitioned ordered topics guarantee order.
Per-channel TPSLimited per LiteTopic (single queue). Total TPS scales with the number of LiteTopics.TPS scales horizontally by queue count and cluster nodes.
Subscription consistencyFlexible: each consumer in the same group can subscribe to a different set of LiteTopics.Strict: all consumers in the same group must share the same subscription.
Consumption modeOrdered only. Each LiteTopic is processed by one consumer thread.Ordered or concurrent.
Dynamic subscriptionConsumers can add or remove LiteTopic subscriptions at runtime.Not supported.
Per-consumer subscription scaleUp to thousands of LiteTopics per consumer.Not applicable.
ObservabilityMessage accumulation metrics available. Message processing latency metrics not available.Both accumulation and latency metrics available.
Message traceSupported.Supported.

Use cases

Asynchronous communication for Multi-Agent systems

As AI workflows grow more complex, single agents are giving way to Multi-Agent architectures. Because AI tasks are long-running, synchronous inter-agent calls block the caller's thread and create scalability bottlenecks.

Multi-Agent asynchronous communication

In this pattern, a Supervisor Agent splits a request and assigns sub-tasks to domain-specific sub-agents. The asynchronous communication flow is as follows:

Request flow:

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

  2. The Supervisor Agent sends the split task information to the corresponding request topics.

Response flow:

  1. The Supervisor Agent creates a Lite-type response topic and subscribes to it.

  2. Each sub-agent processes its task and sends the result to a LiteTopic within the response topic. Name the LiteTopic after the task ID to create a dedicated channel per task.

  3. The Supervisor Agent retrieves results in real time and pushes them to the web client through HTTP Server-Sent Events (SSE).

Distributed session state management for AI applications

AI applications rely on long-running, multi-turn sessions. When a persistent connection (such as SSE or WebSocket) breaks due to a gateway restart, timeout, or network instability, the session context and in-progress AI computation can be lost.

Distributed session state management

LiteTopics decouple session state from the connection. Name each LiteTopic after the session ID (for example, chatbot/{sessionID}). Session results are transmitted in order as messages within the LiteTopic.

When a persistent connection breaks and reconnects to a different node:

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

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

  3. The large model task scheduler sends results to chat/SessionID2 based on the session ID in the request.

  4. A network issue causes the connection to reconnect to application service node 2.

  5. Application service node 1 unsubscribes from chat/SessionID2. Application service node 2 subscribes to chat/SessionID2.

  6. The LiteTopic continues to push unconsumed messages to application service node 2 from the previous consumption offset, preserving session continuity.

Sample code

All examples use the RocketMQ gRPC 5.x SDK. For complete samples, see the RocketMQ 5.x gRPC SDK documentation.

Send messages

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

final Message message = provider.newMessageBuilder()
    .setTopic(topic)
    // Set the message key for tracing.
    .setKeys("messageKey")
    // Route to a specific LiteTopic.
    .setLiteTopic("lite-topic-1")
    // Set the 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

Use the LitePushConsumer class to consume messages from LiteTopics:

// Initialize LitePushConsumer with consumer group, topic, and communication parameters.
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 the LiteTopics relevant to your workload.
    litePushConsumer.subscribeLite("lite-topic-1");
    litePushConsumer.subscribeLite("lite-topic-2");
    litePushConsumer.subscribeLite("lite-topic-3");
} catch (LiteSubscriptionQuotaExceededException e) {
    // The subscription 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);
}

// Unsubscribe from LiteTopics that are no longer needed to release resources.
litePushConsumer.unsubscribeLite("lite-topic-3");

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

Modify subscriptions at runtime

/**
 * subscribeLite() initiates a network request and performs quota verification,
 * so the call may fail. Always check the result to confirm the subscription
 * was added successfully.
 *
 * Possible failure scenarios:
 * 1. A network error occurs. Retry the operation.
 * 2. Quota verification fails with a LiteSubscriptionQuotaExceededException.
 *    Evaluate your quota and use unsubscribeLite() to release unused subscriptions.
 */

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

// Remove a subscription when no longer needed.
litePushConsumer.unsubscribeLite("lite-topic-1");

Limitations

LimitValueAdjustable
Maximum LiteTopics per consumer2,000Yes, via ticket
Maximum consumption TPS per LiteTopic200Submit a ticket to consult

Instance-level quotas also apply to the total number of LiteTopics that can be created or subscribed to. These quotas depend on your instance type and specifications. Submit a ticket to adjust them.

LiteTopic creation quota

The creation quota is the total number of active LiteTopics within a single instance. If this limit is reached and a client sends a message to a non-existent LiteTopic (which would trigger auto-creation), the system rejects the message.

LiteTopic subscription quota

The subscription quota is the sum of all active subscription relationships between all online consumers and LiteTopics within an instance. If this limit is reached, new subscription attempts fail.

Note

Even if a LiteTopic has been deleted, any consumer that still holds a subscription to it counts toward the subscription quota until the consumer explicitly unsubscribes.

Serverless instances (dedicated, reserved + elastic)

Specifications (TPS)Maximum LiteTopics (created or subscribed)
5,000300,000
10,000600,000
15,000720,000
20,000 - 50,0001,000,000
50,001 - 100,0001,500,000
100,001 - 200,0002,400,000
200,001 - 300,0004,700,000
300,001 - 500,0006,300,000
500,001 - 1,000,00011,600,000

Non-serverless instances (subscription and pay-as-you-go)

Standard edition

Instance typeBase TPS (messages/s)Maximum LiteTopics (created or subscribed)
rmq.s2.2xlarge2,000150,000
rmq.s2.4xlarge4,000250,000
rmq.s2.6xlarge6,000300,000

Professional edition

Instance typeBase TPS (messages/s)Maximum LiteTopics (created or subscribed)
rmq.p2.2xlarge2,000150,000
rmq.p2.4xlarge4,000250,000
rmq.p2.6xlarge6,000300,000
rmq.p2.10xlarge10,000600,000
rmq.p2.20xlarge20,000800,000
rmq.p2.30xlarge30,0001,000,000
rmq.p2.40xlarge40,0001,200,000
rmq.p2.50xlarge50,0001,400,000
rmq.p2.100xlarge100,0002,200,000
rmq.p2.120xlarge120,0002,700,000
rmq.p2.150xlarge150,0003,300,000
rmq.p2.200xlarge200,0004,500,000

Platinum edition

Instance typeBase TPS (messages/s)Maximum LiteTopics (created or subscribed)
rmq.u2.10xlarge10,000600,000
rmq.u2.20xlarge20,000800,000
rmq.u2.30xlarge30,0001,000,000
rmq.u2.40xlarge40,0001,200,000
rmq.u2.50xlarge50,0001,400,000
rmq.u2.60xlarge60,0001,600,000
rmq.u2.70xlarge70,0001,700,000
rmq.u2.80xlarge80,0001,800,000
rmq.u2.90xlarge90,0002,000,000
rmq.u2.100xlarge100,0002,200,000
rmq.u2.120xlarge120,0002,700,000
rmq.u2.150xlarge150,0003,300,000
rmq.u2.200xlarge200,0004,500,000
rmq.u2.250xlarge250,0005,600,000
rmq.u2.300xlarge300,0006,300,000
rmq.u2.350xlarge350,0007,500,000
rmq.u2.400xlarge400,0009,300,000
rmq.u2.450xlarge450,00010,400,000
rmq.u2.500xlarge500,00011,600,000
rmq.u2.550xlarge550,00012,800,000
rmq.u2.600xlarge600,00014,000,000
rmq.u2.1000xlarge1,000,00023,200,000

Related resources