Queries online group IDs that have subscribed to a specified topic.

Usage notes

You can call this operation to query the subscriptions between a group ID and a topic. No data is returned if all consumers under the group ID are offline.

QPS limit

The queries-per-second (QPS) limit on this operation is 10 per user. Throttling is triggered when the number of calls to this operation per second exceeds the QPS limit. Throttling may affect your business. Therefore, call this operation based on your needs. For more information, see QPS limits.

Authorization information

By default, only Alibaba Cloud accounts can call this operation. RAM users can call this operation only after they are authorized to use it. The following table lists the authorization information of this operation. For more information, see Policies and examples.

API

Action

Resource (with namespace)

Resource (without namespace)

OnsTopicSubDetail

mq:QueryTopicSubDetail

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

acs:mq:*:*:{topic}

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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 instance where the topic you want to query is located.

Topic String Yes test

The name of the topic that you want to query.

Response parameters

Parameter Type Example Description
Data Struct

The returned data object.

SubscriptionDataList Array of SubscriptionDataList

All online group IDs that have subscribed to the topic.

SubscriptionDataList
GroupId String GID_test

The group ID that has subscribed to the topic.

MessageModel String CLUSTERING

The consumption mode of the group ID that has subscribed to the topic. Valid values:

  • CLUSTERING: clustering consumption
  • BROADCASTING: broadcasting consumption

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

SubString String *

The subscription expression of the group ID that has subscribed to the topic.

Topic String test

The name of the topic.

RequestId String 87B6207F-2908-42B5-A134-84956DCA****

The ID of the request, which is a common parameter. Each request has a unique ID to facilitate troubleshooting and fault locating.

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

<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

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

Operations in the console

In addition to calling the OnsTopicSubDetail operation, you can view the subscriptions between a group ID and a topic in the Message Queue for Apache RocketMQ console. For more information, see View subscriptions.