Queries the information about message accumulation of the topics to which a specified consumer group subscribes. The returned information includes the number of queued messages and the consumption latency.

Note

You can call this operation in scenarios in which you want to know the message consumption progress of a specified consumer group. You can obtain the information about message consumption and consumption latency based on the returned information. This operation returns the total number of queued messages in all topics to which the specified consumer group subscribes and the number of queued messages in each topic.

Note If you want to query the information about message consumption of each online consumer in a consumer group, call the OnsConsumerStatus operation.

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

OnsConsumerAccumulate

mq:QueryInstanceBaseInfo

mq:QueryConsumerAccumulate

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

acs:mq:*:*:{groupId}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsConsumerAccumulate

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

GroupId String Yes GID_test_consumer_id

The ID of the consumer group that you want to query.

Detail Boolean No true

Specifies whether to query the details of each topic to which the consumer group subscribes. Valid values:

  • true: The details of each topic are queried. You can obtain the details from the DetailInTopicList response parameter.
  • false: The details of each topic are not queried. This is the default value. If you specify this value, the value of the DetailInTopicList response parameter is empty.
InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the instance to which the specified consumer group belongs.

Response parameters

Parameter Type Example Description
RequestId String CE817BFF-B389-43CD-9419-95011AC9****

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 information about message accumulation of topics to which the consumer group subscribes.

ConsumeTps Float 10

The transactions per second (TPS) for message consumption performed by consumers in the group.

DelayTime Long 10000

The consumption latency of the consumer group.

LastTimestamp Long 1566231000000

The point in time when the latest message that was consumed by a consumer in the consumer group was produced.

TotalDiff Long 100

The total number of queued messages in all topics to which the consumer group subscribes.

Online Boolean true

Indicates whether the consumer group is online. The group is online if one of the consumers in the group is online. Valid values:

  • true: The consumer group is online.
  • false: The consumer group is offline.
DetailInTopicList Array of DetailInTopicDo

The information about each topic to which the consumer group subscribes. If the Detail parameter in the request is set to false, the value of this parameter is empty.

DetailInTopicDo
DelayTime Long 10000

The maximum latency of message consumption in the topic.

TotalDiff Long 100

The number of queued messages in the topic.

LastTimestamp Long 1566231000000

The point in time when the latest consumed message in the topic was produced.

Topic String test-mq-topic

The name of the topic.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=OnsConsumerAccumulate
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&GroupId=GID_test_consumer_id
&Detail=true
&<Common request parameters>

Sample success responses

XML format

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

<OnsConsumerAccumulateResponse>
<Data>
    <DetailInTopicList>
        <DetailInTopicDo>
            <TotalDiff>100</TotalDiff>
            <LastTimestamp>1566231000000</LastTimestamp>
            <DelayTime>10000</DelayTime>
            <Topic>test-mq-topic</Topic>
        </DetailInTopicDo>
    </DetailInTopicList>
    <TotalDiff>100</TotalDiff>
    <LastTimestamp>1566231000000</LastTimestamp>
    <DelayTime>10000</DelayTime>
    <Online>true</Online>
    <ConsumeTps>10</ConsumeTps>
</Data>
<RequestId>0CCF6437-CBB0-4378-BFEC-E08AC258****</RequestId>
</OnsConsumerAccumulateResponse>

JSON format

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

{
  "Data" : {
    "DetailInTopicList" : {
      "DetailInTopicDo" : [ {
        "TotalDiff" : 100,
        "LastTimestamp" : 1566231000000,
        "DelayTime" : 10000,
        "Topic" : "test-mq-topic"
      } ]
    },
    "TotalDiff" : 100,
    "LastTimestamp" : 1566231000000,
    "DelayTime" : 10000,
    "Online" : true,
    "ConsumeTps" : 10
  },
  "RequestId" : "0CCF6437-CBB0-4378-BFEC-E08AC258****"
}

Error codes

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

View the information about message accumulation in the console

In the Message Queue for Apache RocketMQ console, you can view the information about message accumulation of topics to which a consumer group subscribes. For more information, see View the status of consumers.