Queries the total number of messages in a topic and the time when the topic was last updated.

Usage notes

You can call this operation to determine the topic resource usage. The information returned after you call this operation includes the total number of messages in the topic on the current Message Queue for Apache RocketMQ broker and the time when the last message was written into the topic.

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)

OnsTopicStatus

mq:QueryTopicStatus

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 OnsTopicStatus

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

InstanceId String Yes MQ_INST_188077086902****_BXSuW61e

The ID of the instance where the topic you want to query is located.

Topic String Yes test

The name of the topic that you want to query.

Response parameters

Parameter Type Example Description
Data Struct

The data structure of the queried topic.

LastTimeStamp Long 1570864984364

The time when the topic was last updated.

Perm Integer 6

The number of the relationship between the API caller and the topic. Valid values:

  • 2: The API caller can publish messages to the topic.
  • 4: The API caller can subscribe to the topic.
  • 6: The API caller can publish messages to and subscribe to the topic.
TotalCount Long 2310

The total number of messages in all partitions of the topic.

RequestId String 427EE49D-D762-41FB-8F3D-9BAC96C3****

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=OnsTopicStatus
&InstanceId=MQ_INST_188077086902****_BXSuW61e
&Topic=test
&<Common request parameters>

Sample success responses

XML format

<OnsTopicStatusResponse>
  <Data>
        <Perm>6</Perm>
        <TotalCount>2310</TotalCount>
        <LastTimeStamp>1570864984364</LastTimeStamp>
  </Data>
  <RequestId>427EE49D-D762-41FB-8F3D-9BAC96C3****</RequestId>
</OnsTopicStatusResponse>

JSON format

{
    "Data": {
        "Perm": 6,
        "TotalCount": 2310,
        "LastTimeStamp": 1570864984364
    },
    "RequestId": "427EE49D-D762-41FB-8F3D-9BAC96C3****"
}

Error codes

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