Creates a topic.
- You can send a maximum of one query per second (QPS).
- The maximum number of topics that can be created on an instance depends on the specifications of the instance.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateTopic |
The operation that you want to perform. Set the value to CreateTopic. |
InstanceId | String | Yes | alikafka_pre-cn-mp919o4v**** |
The ID of the Message Queue for Apache Kafka instance on which you want to create the topic. |
Topic | String | Yes | alikafka_topic_test |
The name of the topic.
|
Remark | String | Yes | alikafka_topic_test |
The description of the topic.
|
RegionId | String | Yes | cn-hangzhou |
The region ID of the Message Queue for Apache Kafka instance. |
CompactTopic | Boolean | No | false |
The log cleanup policy for the topic. This parameter is available when the Local Storage mode is specified for the topic. Valid values:
|
PartitionNum | String | No | 12 |
The number of partitions in the topic.
|
LocalTopic | Boolean | No | false |
The storage engine of the topic. Valid values:
|
ReplicationFactor | Long | No | 3 |
The number of replicas of the topic.
Note If you set this parameter to 1, the risk of data loss increases. Proceed with caution.
|
MinInsyncReplicas | Long | No | 1 |
The minimum number of in-sync replicas.
|
Config | Map | No | null |
Additional configurations.
Note If you set this parameter to specify the number of replicas of the topic, the ReplicationFactor parameter no longer takes effect.
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | Integer | 200 |
The HTTP status code. The HTTP status code 200 indicates that the request is successful. |
Message | String | operation success |
The returned message. |
RequestId | String | 9C0F207C-77A6-43E5-991C-9D98510A**** |
The ID of the request. |
Success | Boolean | true |
Indicates whether the request is successful. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateTopic
&InstanceId=alikafka_pre-cn-mp919o4v****
&RegionId=cn-hangzhou
&Remark=alikafka_topic_test
&Topic=alikafka_topic_test
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateTopicResponse>
<RequestId>9C0F207C-77A6-43E5-991C-9D98510A****</RequestId>
<Message>operation success</Message>
<Code>200</Code>
<Success>true</Success>
</CreateTopicResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "9C0F207C-77A6-43E5-991C-9D98510A****",
"Message" : "operation success",
"Code" : 200,
"Success" : true
}
Error codes
For a list of error codes, visit the API Error Center.