Before you send or receive messages with ApsaraMQ for Kafka, create topics and consumer groups on your deployed instance. Producers send messages to topics. Consumers read messages from topics through consumer groups. Before consumers can consume messages, the consumer group must subscribe to the corresponding topics. A consumer group can subscribe to multiple topics, and a topic can serve multiple consumer groups.
Prerequisites
Before you begin, make sure that you have:
A purchased and deployed ApsaraMQ for Kafka instance
Step 1: Create a topic
Create topics in the same region as the Elastic Compute Service (ECS) instance where your producers and consumers run. Topics cannot be used across regions. For example, if your ECS instance is in the China (Beijing) region, the topic must also be in the China (Beijing) region.
Log on to the ApsaraMQ for Kafka console.
In the Resource Distribution section of the Overview page, select the region where your instance is deployed.
On the Instances page, click the name of your instance.
In the left-side navigation pane, click Topics.
On the Topics page, click Create Topic.
In the Create Topic panel, configure the following parameters and click OK. After the topic is created, it appears on the Topics page.
Parameter Description Example Name The topic name. demo Description A brief description of the topic. demo test Partitions The number of partitions. 12 Storage Engine The storage engine type. Available only for Professional Edition instances. Standard Edition defaults to Cloud Storage. For details, see the Storage engine options section below. Cloud Storage Message Type The message ordering behavior. Automatically determined by the storage engine. For details, see the Message type options section below. Normal Message Log Cleanup Policy Required only when Storage Engine is Local Storage (Professional Edition). For details, see the Log cleanup policy options section below. Delete Tag Tags to attach to the topic. demo
The system automatically creates two internal topics when you deploy an instance: __alikafka_housekeeping_local_topic and __alikafka_housekeeping_cloud_topic. Do not delete these topics. For more information, see Inspection description.
Storage engine options
This parameter is available only for Professional Edition instances. Standard Edition instances use Cloud Storage by default.
Cloud Storage: Stores messages on Alibaba Cloud disks with three replicas in distributed mode. Provides low latency, high performance, high durability, and high reliability. If you set Instance Edition to Standard (High Write) during instance creation, only Cloud Storage is available.
Local Storage: Uses the in-sync replicas (ISR) algorithm from open source Apache Kafka. Stores data in three replicas in distributed mode.
Message type options
Normal Message: Messages with the same key are stored in the same partition in send order. If a broker fails, message ordering across partitions may not be preserved. Automatically set when Storage Engine is Cloud Storage.
Partitionally Ordered Message: Messages with the same key are stored in the same partition in send order. If a broker fails, ordering is preserved, but some partitions become unavailable until the broker recovers. Automatically set when Storage Engine is Local Storage.
Log cleanup policy options
Required only when Storage Engine is Local Storage (Professional Edition only).
Delete (default): Retains messages based on the maximum retention period. When storage usage exceeds 85%, the system deletes the earliest messages to maintain service availability.
Compact: Applies the log compaction policy from Apache Kafka. Retains only the latest value for each message key. Use this policy for components that store state or configuration data, such as Kafka Connect and Confluent Schema Registry. For more information, see aliware-kafka-demos.
ImportantLog-compacted topics are supported only for specific cloud-native components such as Kafka Connect and Confluent Schema Registry.
Step 2: Create a consumer group
Log on to the ApsaraMQ for Kafka console.
In the Resource Distribution section of the Overview page, select the region where your instance is deployed.
On the Instances page, click the name of your instance.
In the left-side navigation pane, click Groups.
On the Groups page, click Create Group.
In the Create Group panel, enter a group name in the Group ID field and a description in the Description field, attach tags if needed, and click OK. After the consumer group is created, it appears on the Groups page.
What's next
After creating topics and consumer groups, use an SDK to produce and consume messages. See Step 4: Use an SDK to send and receive messages.
Related topics
To enable automatic resource creation, see Automatically create topics and Use the flexible group creation feature.
To create resources programmatically, see the CreateTopic and CreateConsumerGroup API references.