Creates a topic.

Usage notes

You can call this operation when new topics are required to publish new applications or expand your business.

QPS limit

A user can perform a maximum of one query per second (QPS). When the number of calls to this operation per second exceeds the QPS limit, throttling is triggered. If throttling is triggered, your business may be affected. We recommend that you take note of the QPS limit on this operation. 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 these RAM users are granted related permissions. The following table describes the authorization information of this operation. For more information, see Policies and examples.

Operation

Action

Resource that has a namespace

Resource that has no namespace

OnsTopicCreate

mq:CreateTopic

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

acs:mq:*:*:{topic}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTopicCreate

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

Topic String Yes test

The name of the topic to be created. Take note of the following items:

  • The name must be 3 to 64 characters in length and can contain letters, digits, hyphens (-), and underscores (_).
  • The topic name cannot start with CID or GID because CID and GID are reserved fields for group IDs.
  • If the instance where the topic to be created resides has a namespace, the name of the topic must be unique in the instance. Specifically, the name cannot be the same as an existing topic name or group ID in the instance. Topic names and group IDs in different instances can be the same. For example, a topic name in Instance A can be the same as a topic name or group ID in Instance B.
  • If the instance where the topic to be created resides has no namespace, the name of the topic must be globally unique across instances and regions. Specifically, the name of the topic cannot be the same as an existing topic name or group ID in Message Queue for Apache RocketMQ within your Alibaba Cloud account.
Note You can check whether an instance has a namespace in the Basic Information section on the Instance Details page in the Message Queue for Apache RocketMQ console.
MessageType Integer Yes 0

The type of message in the topic. Valid values:

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

For more information, see Overview.

Remark String No Test

The description of the topic to be created.

InstanceId String Yes MQ_INST_188077086902****_BXSuW61e

The ID of the instance where the topic to be created resides.

Response parameters

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

The ID of the request. This is a common parameter. Each request has a unique ID. This facilitates 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

HTTP/1.1 200 OK
Content-Type:application/xml

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

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

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

Operation in the Message Queue for Apache RocketMQ 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.