A topic is a top-level message category in ApsaraMQ for RocketMQ. ApsaraMQ for RocketMQ supports a publish/subscribe model. Producers publish messages to topics, and consumers receive messages by subscribing to them. You can create, delete, update, and query topics in the ApsaraMQ for RocketMQ console.
Usage notes
-
Topics cannot be used across instances. For example, a topic created in Instance A cannot be used in Instance B.
-
The topic type must match the message type. For example, if you create a topic for normal messages, select normal message as the message type. Do not select other types such as ordered message or transactional message. A mismatch can cause issues such as the loss of scheduled/delayed messages during node replacement or instance migration.
-
In RocketMQ 5.x, the system automatically assigns the number of queues per topic. You cannot customize or modify the queue count, nor can you view the count through the console or API.
-
ApsaraMQ for RocketMQ does not support creating global-order topics directly, nor does it provide a special application channel for this purpose. To achieve globally ordered messages, create a FIFO (partitioned order) topic and set the same Sharding Key (for example, a fixed value) when sending messages. This routes all messages to the same partition for in-order processing.
-
ApsaraMQ for RocketMQ 5.x does not support automatic topic creation, including dead letter topics. You must create dead letter topics explicitly through the console or API. This differs from the open-source version of RocketMQ, which supports automatic topic creation.
Billing
Topic billing depends on the billing method of your ApsaraMQ for RocketMQ instance.
-
Subscription and pay-as-you-go instances
You are charged only for topics that exceed the free quota of your instance. No fees are incurred if you stay within the free quota. For more information, see Topic fees.
-
Serverless instances
You are charged based on the number of topics. For more information, see Topic fees for serverless instances.
Create a topic
Log on to the ApsaraMQ for RocketMQ console. In the left-side navigation pane, click Instances.
In the top navigation bar, select a region, such as China (Hangzhou). On the Instances page, click the name of the instance that you want to manage.
-
In the left-side navigation pane, click Topics.
-
On the Topics page, click Create Topic.
-
In the Create Topic panel, enter a Name and Description, select a message type, and then click OK.
You can select normal message, ordered message, scheduled/delayed message, or transactional message. The topic name must be 1 to 60 characters long and can contain only letters, digits, hyphens (-), and underscores (_).
List topics
Log on to the ApsaraMQ for RocketMQ console. In the left-side navigation pane, click Instances.
In the top navigation bar, select a region, such as China (Hangzhou). On the Instances page, click the name of the instance that you want to manage.
-
In the left-side navigation pane, click Topics.
-
On the Topics page, you can view all topics in the current instance.
View topic details
-
On the Topics page, find the target topic and click Details in the Actions column.
-
On the Topic Details page, you can view the topic details.
Edit a topic
-
On the Topics page, find the target topic and click Details in the Actions column.
-
On the Topic Details page, click the Basic Information tab. Then, in the Basic Information section, click Edit.
-
In the Update Topic panel, update the topic description and click OK.
Delete a topic
-
Deleting a topic immediately stops its producers and consumers. The topic's metadata and message data are permanently deleted and cannot be restored. Proceed with caution.
-
You must wait five minutes before you can create another topic with the same name.
-
On the Topics page, find the target topic and click Details in the Actions column.
-
On the Topic Details page, click the Basic Information tab. Then, in the Basic Information section, click Delete Topic.
-
In the Note dialog box, click OK.
Quick start
You can quickly test sending normal messages in the ApsaraMQ for RocketMQ console. To send and receive other message types, use an SDK. For more information, see SDK reference overview.
-
On the Topics page, find a topic whose Message Type is normal message, and click Details in the Actions column.
-
On the Topic Details page, click Quick Start.
-
In the Start Message Production and Consumption panel, perform one of the following actions:
-
Console:
Enter Message Body, Message Key, and Message Tag, and then click OK.
-
SDK:
View the code samples for different SDKs and follow the instructions to send and receive messages.
-
View the dashboard
The dashboard displays key metrics for message production and producer clients. For more information, see dashboard.
-
On the Topics page, find the target topic and click Details in the Actions column.
-
On the Topic Details page, click the Dashboard tab.
More operations
For information about importing and exporting topics, see Import and export topics.
FAQ
Q: What should I do if I get an InternalError or a message indicating that MessageType is missing when creating a topic by using Alibaba Cloud CLI?
When you create a topic by using Alibaba Cloud CLI, the MessageType parameter is required and has no default value. Valid values: NORMAL, FIFO, DELAY. If you omit this parameter, topic creation fails or returns an InternalError.
Q: What should I do if the OnsTopicStatus API call returns a BIZ_RESOURCE_NOT_EXISTS error?
This error typically means the target topic does not exist in the specified instance. Troubleshoot as follows:
-
Verify that the instance ID and topic name used in the API call are correct.
-
Ensure that the target topic exists in the specified instance.
-
Note that topics cannot be used across instances.
Q: How do I query the operation records and the operator of a deleted RocketMQ topic?
Log on to the ActionTrail console and search for the event name OnsTopicDelete or ConsoleTopicDelete. Filter by region to view deletion records and operator account information.
Audit logs are retained for a maximum of 90 days. Records older than 90 days cannot be queried.
Q: What should I do if I get a message type mismatch error when multiple projects have producers for the same FIFO topic?
This error is unrelated to multi-project coexistence. The root cause is that the topic is configured as FIFO (ordered messages), but the client sends messages identified as NORMAL (normal messages). To resolve this issue:
-
Check the message definition and sending method in your code.
-
Ensure that you are using the correct FIFO message sending API.
-
Verify that the message attributes comply with FIFO requirements.
-
Make sure that the topic type and the message type are consistent.
Related documents
You can also manage topics by calling these API operations: