Deletes a topic.

Usage notes

You can call this operation to delete a topic when you need to deallocate the resources of the topic. For example, after an application is brought offline, you can delete the topics that are used for the application.

After you delete the topic, the backend of Message Queue for Apache RocketMQ deallocates the resources of the topic. The system requires a long period of time to deallocate the resources. We recommend that you do not create a topic that uses the same name as a deleted topic immediately after you delete the topic. If the system fails to delete the specified topic, troubleshoot the issue based on the error code.

Note After you delete the topic, the publishing and subscription relationships that are constructed based on the topic are cleared. Exercise caution when you call this operation.

Request limit

Each Alibaba Cloud account can call this operation up to 10 times per second. If the number of requests that you send to call this operation within 1 second reaches the request limit, new requests fail. This may interrupt your business. For information about the request limit of each operation, see API rate limits.

Authorization

By default, only Alibaba Cloud accounts can call this operation. A Resource Access Management (RAM) user can call this operation only after the RAM user is granted the required permissions. The following table describes the permissions that must be granted to a RAM user to call this operation. For information about how to grant permissions, Policies and examples.

API

Action

Resource in an instance that uses a namespace

Resource in an instance that does not use a namespace

OnsTopicDelete

mq:QueryInstanceBaseInfo

mq:DeleteTopic

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

acs:mq:*:*:{topic}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTopicDelete

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

Topic String Yes test

The name of the topic that you want to delete.

InstanceId String Yes MQ_INST_188077086902****_BXSuW61e

The ID of the Message Queue for Apache RocketMQ instance that contains the specified topic.

Response parameters

Parameter Type Example Description
RequestId String 4189D4A6-231A-4028-8D89-F66A76C1****

The ID of the request. The system generates a unique ID for each request. You can troubleshoot issues based on the request ID.

Examples

Sample requests

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

Sample success responses

XML format

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

<OnsTopicDeleteResponse>
<RequestId>4189D4A6-231A-4028-8D89-F66A76C1****</RequestId>
</OnsTopicDeleteResponse>

JSON format

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

{
  "RequestId" : "4189D4A6-231A-4028-8D89-F66A76C1****"
}

Error codes

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

Delete a topic in the console

You can also delete a topic in the Message Queue for Apache RocketMQ console. For more information, see Manage topics.