Getting Topic Properties

Last updated: 2019-07-05 15:06:26

PDF

1. API Description

This API (GetTopicAttributes) is used to get the attributes of a created topic. In addition to the configurable attributes that are configured when a topic is created, the returned attributes also include the topic creation time (createTime), the time when the topic attributes were last modified (lastModifyTime) and the statistics about the messages in the topic (approximate value).

Domain for public network API request: cmq-topic-region.api.qcloud.com

Domain for private network API request: cmq-topic-region.api.tencentyun.com

Whenever (including during alpha test) any public network downstream traffic is generated from the use of a public network domain, a fee will be charged. It is strongly recommended that users whose services are on the Tencent Cloud use private network domains, because no fee will be charged for the traffic consumed in the private network.

  • region should be replaced with a specific region: gz (Guangzhou), sh (Shanghai), or bj (Beijing). The region value in the common parameters should be consistent with the region value of the domain. If there is an inconsistency, the request will be sent to the region specified by the domain.
  • Public network domain requests both support http and https. Private network requests only support http.
  • Some of the input parameters are optional. If not specified, the default value will be taken.
  • All the output parameters will be returned to the user when the request is successful; otherwise, at least code, message, and requestId will be returned.

2. Input Parameters

The following request parameter list only provides API request parameters. For other parameters, refer to Common Request Parameters.

Parameter Name Required Type Description
topicName Yes String Topic name. It is unique under the same account in one region. The topic name is a string of no more than 64 characters, which can contain letters, numbers, and hyphens (-) and must begin with a letter.

3. Output Parameters

Parameter Name Type Description
code Int 0: Succeeded; 4440: Topic does not exist. For the meanings of other returned values, please refer to Error Codes.
message String Error message.
requestId String ID of the request generated by server. When there is an internal error on the server, users can submit this ID to the backend to locate the problem.
msgCount Int Current number of messages in the topic (number of retained messages).
maxMsgSize Int Maximum message length. Value range is 1024-65536 Bytes (1-64 K). Default is 65536.
msgRetentionSeconds Int The maximum available time of the message in the topic (in seconds). A message will be deleted no matter whether or not it is successfully pushed to users after the period of time specified by this parameter. This parameter value is always one day (86,400 seconds) and cannot be modified.
createTime Int Topic creation time. A Unix timestamp will be returned (accurate to second).
lastModifyTime Int The time when the topic attributes were last modified. A Unix timestamp will be returned (accurate to second).
filterType Int Indicate the filtering policy that a user selects when creating a subscription:
filterType = 0 indicates that filterTag is used for filtering;
filterType = 1 indicates that bindingKey is used for filtering.

4. Example

Input:

 https://domain/v2/index.php?Action=GetTopicAttributes
 &topicName=test-topic-123
 &<Common request parameters>

Output:

{
"code" : 0,
"message" : "",
"requestId":"14534664555",
"msgCount":234
"maxMsgSize": 65536,
"msgRetentionSeconds": 1296000,
"createTime":1462268960,
"lastModifyTime": 1462269960,
"filterType":0
}