Queries the online consumer groups that subscribe to a specified topic.

Note

You can call this operation to query the online consumer groups that subscribe to a specified topic. If all consumers in a group are offline, the information about the group is not returned.

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, new requests fail. This may interrupt your business. If the number of requests that you send to call this operation within one second reaches the request limit, new requests fail. This may interrupt your business. For information about the request limit of each operation, see API request limits.

Authorization

By default, 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.

API

Action

Resource in an instance that uses a namespace

Resource in an instance that does not use a namespace

OnsTopicSubDetail

mq:QueryInstanceBaseInfo

mq:QueryTopicSubDetail

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

acs:mq:*:*:{topic}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTopicSubDetail

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

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

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

Topic String Yes test

The name of the topic that you want to query.

Response parameters

Parameter Type Example Description
RequestId String 87B6207F-2908-42B5-A134-84956DCA****

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.

SubscriptionDataList Array of SubscriptionDataList

The information about the online consumer groups that subscribe to the topic.

SubscriptionDataList
GroupId String GID_test

The ID of the consumer group.

MessageModel String CLUSTERING

The consumption mode. Valid values:

  • CLUSTERING: the clustering mode
  • BROADCASTING: the broadcasting mode

For more information about consumption modes, see Clustering consumption and broadcasting consumption.

SubString String *

The expression based on which consumers in the consumer group subscribe to the topic.

Topic String test

The name of the topic.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=OnsTopicSubDetail
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&Topic=test
&<Common request parameters>

Sample success responses

XML format

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

<OnsTopicSubDetailResponse>
<Data>
    <Topic>test</Topic>
    <SubscriptionDataList>
        <SubscriptionDataList>
            <SubString>*</SubString>
            <MessageModel>CLUSTERING</MessageModel>
            <GroupId>GID_test</GroupId>
        </SubscriptionDataList>
    </SubscriptionDataList>
</Data>
<RequestId>87B6207F-2908-42B5-A134-84956DCA****</RequestId>
</OnsTopicSubDetailResponse>

JSON format

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

{
  "Data" : {
    "Topic" : "test",
    "SubscriptionDataList" : {
      "SubscriptionDataList" : [ {
        "SubString" : "*",
        "MessageModel" : "CLUSTERING",
        "GroupId" : "GID_test"
      } ]
    }
  },
  "RequestId" : "87B6207F-2908-42B5-A134-84956DCA****"
}

Error codes

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

View consumer groups that subscribe to a topic in the console

In the Message Queue for Apache RocketMQ console, you can view the information about the online consumer groups that subscribe to a topic. For more information, see View subscriptions.