Creates a topic.

Usage notes

You can call this operation when new topics are required to publish new applications or implement service logic.

QPS limit

The queries-per-second (QPS) limit on this operation is 1 per user. Throttling is triggered when the number of calls to this operation per second exceeds the QPS limit. Throttling may affect your business. Therefore, call this operation based on your needs. For more information, see QPS limits.

Authorization information

By default, only Alibaba Cloud accounts can call this operation. RAM users can call this operation only after they are authorized to use it. The following table lists the authorization information of this operation. For more information, see Policies and examples.

API

Action

Resource (with namespace)

Resource (without namespace)

OnsTopicCreate

mq:CreateTopic

acs:mq:*:*:{instanceId}%{topic}

acs:mq:*:*:{topic}

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTopicCreate

The operation that you want to perform. Set the value to OnsTopicCreate.

InstanceId String Yes MQ_INST_188077086902****_BXSuW61e

The ID of the instance where you want to create the topic.

MessageType Integer Yes 0

The type of messages in the topic. Valid values:

  • 0: normal messages
  • 1: partitionally ordered messages
  • 2: globally ordered messages
  • 4: transactional messages
  • 5: scheduled or delayed messages

For more information about each type of message, see Overview.

Topic String Yes test

The name of the topic that you want to create.

  • CID and GID are the reserved fields of a group ID. A topic name cannot start with CID or GID.
  • If a namespace is configured for the instance where you want to create the topic, the topic name must be unique within the instance but can be the same as topic names in other instances.
  • If no namespace is configured for the instance where you want to create the topic, the topic name must be globally unique within the instance and across instances and regions.
Remark String No Test

The description of the topic that you want to create.

Response parameters

Parameter Type Example Description
RequestId String B6949B58-223E-4B75-B4FE-7797C15E****

The ID of the request, which is a common parameter. Each request has a unique ID to facilitate troubleshooting and fault locating.

Examples

Sample requests

http(s)://ons.cn-zhangjiakou.aliyuncs.com/? Action=OnsTopicCreate
&InstanceId=MQ_INST_188077086902****_BXSuW61e
&MessageType=0
&Topic=test
&<Common request parameters>

Sample success responses

XML format

<OnsTopicCreateResponse>
  <RequestId>B6949B58-223E-4B75-B4FE-7797C15E****</RequestId>
</OnsTopicCreateResponse>

JSON format

{
    "RequestId": "B6949B58-223E-4B75-B4FE-7797C15E****"
}

Error codes

For a list of error codes, visit the API Error Center.

Operations in the console

In addition to calling the OnsTopicCreate operation, you can create a topic in the Message Queue for Apache RocketMQ console. For more information, see Manage topics.