Queries the information about topics that can be accessed by the current account.

Usage notes

This operation returns the basic information about topics and does not return the details of topics.

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

API

Action

Resource

OnsTopicList

mq:QueryInstanceBaseInfo

acs:mq:*:*:{instanceId}

Note When you use the credential of a RAM user to call this operation, this operation returns only the information about the topics on which the RAM user is granted the required permissions. To obtain the information about other topics, log on to the RAM console with your Alibaba Cloud account to grant the RAM user the required permissions on the topics that you want to access. For information about how to grant permissions, see Policies and examples.

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTopicList

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

Topic String No test

The name of the topic that you want to query. This parameter is required when you want to query a specific topic. If you do not include this parameter in the request, all topics that you can access are queried.

InstanceId String Yes MQ_INST_188077086902****_BXSuW61e

The ID of the Message Queue for Apache RocketMQ instance that contains the topics you want to query.

Tag.N.Key String Yes CartService

The key of a tag that is attached to the topics you want to query. This parameter is not required. If you configure this parameter, you must also configure the Tag.N.Value parameter. If you include the Tag.N.Key and Tag.N.Value parameters in a request, this operation queries only the topics that use the specified tags. If you do not include these parameters in a request, this operation queries all topics that you can access.

  • The value of N must be an integer value from 1 to 20.
  • If you include this parameter in a request, the value of this parameter cannot be an empty string.
  • The value of this parameter must be up to 128 characters in length and cannot start with acs: or aliyun, or contain http:// or https://.
Tag.N.Value String Yes ServiceA

The value of a tag that is attached to the topics you want to query. This parameter is not required. If you configure this parameter, you must also configure the Tag.N.Key parameter. If you include the Tag.N.Key and Tag.N.Value parameters in a request, this operation queries only the topics that use the specified tags. If you do not include these parameters in a request, this operation queries all topics that you can access.

  • The value of N must be an integer value from 1 to 20.
  • The value of this parameter can be an empty string.
  • The value of this parameter must be up to 128 characters in length and cannot start with acs: or aliyun, or contain http:// or https://.

Response parameters

Parameter Type Example Description
RequestId String 4A978869-7681-4529-B470-107E1379****

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

Data Array of PublishInfoDo

The list of topics.

PublishInfoDo
MessageType Integer 0

The message type. Valid values:

  • 0: normal messages
  • 1: partitionally ordered messages
  • 2: globally ordered messages
  • 4: transactional messages
  • 5: scheduled or delayed messages
RelationName String Publish and subscribe

The name of the relationship between the current account and the topic. The value of this parameter indicates that the current account is the owner of the topic, the current account can publish messages to the topic, the current account can subscribe to the topic, or the current account can publish messages to and subscribe to the topic.

Owner String 138015630679****

The user ID of the topic owner.

IndependentNaming Boolean true

Indicates whether the Message Queue for Apache RocketMQ instance that contains the topic uses a namespace. Valid values:

  • true: The instance uses a namespace. The identifier of each resource in the instance must be unique within the instance. However, the identifier of a resource in the instance can be the same as the identifier of a resource in another instance that uses a different namespace.
  • false: The instance does not use a namespace. The identifier of each resource in the instance must be unique across instances.
Remark String Test

The description of the topic.

Relation Integer 6

Indicates the relationship between the current account and the topic. Valid values:

  • 1: The current account is the owner of the topic.
  • 2: The current account can publish messages to the topic.
  • 4: The current account can subscribe to the topic.
  • 6: The current account can publish messages to and subscribe to the topic.
CreateTime Long 1570700947000

The point in time when the topic was created.

Topic String test

The name of the topic.

Tags Array of Tag

The tags that are attached to the topic.

Tag
Key String CartService

The key of the tag.

Value String SrviceA

The value of the tag.

InstanceId String MQ_INST_188077086902****_BXSuW61e

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

ServiceStatus Integer 0

The status of the topic. Valid values:

  • 0: The topic is being created.
  • 1: The topic is in service.

Examples

Sample requests

http(s)://ons.cn-zhangjiakou.aliyuncs.com/?Action=OnsTopicList
&InstanceId=MQ_INST_188077086902****_BXSuW61e
&Tag.1.Key=CartService
&Tag.1.Value=ServiceA
&<Common request parameters>

Sample success responses

XML format

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

<OnsTopicListResponse>
    <RequestId>4A978869-7681-4529-B470-107E1379****</RequestId>
    <Data>
        <MessageType>0</MessageType>
        <RelationName>Publish and subscribe</RelationName>
        <Owner>138015630679****</Owner>
        <IndependentNaming>true</IndependentNaming>
        <Remark>Test</Remark>
        <Relation>6</Relation>
        <CreateTime>1570700947000</CreateTime>
        <Topic>test</Topic>
        <Tags>
            <Key>CartService</Key>
            <Value>SrviceA</Value>
        </Tags>
        <InstanceId>MQ_INST_188077086902****_BXSuW61e</InstanceId>
        <ServiceStatus>0</ServiceStatus>
    </Data>
</OnsTopicListResponse>

JSON format

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

{
  "RequestId" : "4A978869-7681-4529-B470-107E1379****",
  "Data" : [ {
    "MessageType" : 0,
    "RelationName": "Publish and subscribe",
    "Owner" : "138015630679****",
    "IndependentNaming" : true,
    "Remark": "Test",
    "Relation" : 6,
    "CreateTime" : 1570700947000,
    "Topic" : "test",
    "Tags" : [ {
      "Key" : "CartService",
      "Value" : "SrviceA"
    } ],
    "InstanceId" : "MQ_INST_188077086902****_BXSuW61e",
    "ServiceStatus" : 0
  } ]
}

Error codes

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