All Products
Search
Document Center

ApsaraMQ for RocketMQ:OnsTopicStatus

Last Updated:Jan 06, 2026

Queries the total number of messages in a topic and the status of the topic.

Operation description

Note

API operations provided by Alibaba Cloud are used to manage and query resources of Alibaba Cloud services. We recommend that you integrate these API operations only in management systems. Do not use these API operations in the core system of messaging services. Otherwise, system risks may occur.

You can determine 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.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

mq:QueryTopicStatus

get

Topic

acs:mq:{#regionId}:{#accountId}:{#TopicName}

Topic

acs:mq:{#regionId}:{#accountId}:{#InstanceId}%{#TopicName}

None
  • mq:OnsInstanceBaseInfo

Request parameters

Parameter

Type

Required

Description

Example

Topic

string

Yes

The name of the topic that you want to query.

test

InstanceId

string

No

The ID of the instance that contains the topic you want to query.

MQ_INST_188077086902****_BXSuW61e

Response elements

Element

Type

Description

Example

object

The message returned.

RequestId

string

The ID of the request. This parameter is a common parameter. Each request has a unique ID. You can use this ID to troubleshoot issues.

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

Data

object

The data structure of the queried topic.

Perm

integer

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.

6

LastTimeStamp

integer

The point in time when the latest message is ready in the topic. If no message exists in the topic, the return value of this parameter is 0.

The value of this parameter is a UNIX timestamp in milliseconds.

For information about the definition of ready messages and ready time, see Terms.

1570864984364

TotalCount

integer

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

2310

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.