Queries the total number of messages in a topic and the most recent point in time when a message was published to the topic.

Usage notes

You can obtain the resource usage of a topic based on the information that is returned by this operation. The returned information includes the total number of messages in the topic and the most recent point in time when a message was published to the topic.

Request limit

Each Alibaba Cloud account can call this operation up to once per second. If the number of requests that you send to call this operation within one second reaches the request limit of this operation, 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, see Policies and examples.

API

Action

Resource in an instance that uses a namespace

Resource in an instance that does not use a namespace

OnsTopicStatus

mq:QueryInstanceBaseInfo

mq:QueryTopicStatus

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

acs:mq:*:*:{topic}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTopicStatus

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

Topic String Yes test

The name of the topic that you want to query.

InstanceId String Yes MQ_INST_188077086902****_BXSuW61e

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

Response parameters

Parameter Type Example Description
RequestId String 427EE49D-D762-41FB-8F3D-9BAC96C3****

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

Data Object

The data that is returned.

Perm Integer 6

Indicates the operations that you can perform on the topic. Valid values:

  • 2: You can publish messages to the topic.
  • 4: You can subscribe to the topic.
  • 6: You can publish messages to and subscribe to the topic.
LastTimeStamp Long 1570864984364

The most recent point in time when a message was published to the topic.

TotalCount Long 2310

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

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

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

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

JSON format

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

{
  "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.