Queries the consumption details of a consumer group with a specified group ID, including the subscriptions, consumption transactions per second (TPS), load balancing status, and consumer connection.

Note

  • You can call this operation to troubleshoot abnormal consumption after you confirm whether messages are accumulated and whether consumers are online. In addition, you can check whether subscriptions are consistent for consumers in the same consumer group and whether load balancing is normal, and query the jstack information of online consumers.
  • This operation uses a lot of backend methods for data aggregation. Therefore, the system responds slowly. We recommend that you do not frequently call this operation.

QPS limit

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

Authorization information

By default, only Alibaba Cloud accounts can call this operation. RAM users can call this operation only after the required permissions are granted to them. The following table describes the authorization information of this operation. For more information, see Policies.

API

Action

Resource with a namespace

Resource without a namespace

OnsConsumerStatus

mq:QueryConsumerStatus

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

acs:mq:*:*:{groupId}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsConsumerStatus

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

GroupId String Yes GID_test_group_id

The ID of the consumer group whose consumption details you want to query.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the instance where the consumer group resides.

Detail Boolean No true

Specifies whether to query detailed information. Valid values:

  • true: queries detailed information. You can obtain detailed information from the ConsumerConnectionInfoList and DetailInTopicList parameters in the response.
  • false: does not query detailed information. This is the default value. The ConsumerConnectionInfoList and DetailInTopicList parameters are empty in the response.
NeedJstack Boolean No true

Specifies whether to display jstack information. Valid values:

  • true: displays jstack information. You can obtain jstack information from the Jstack parameter in the response.
    Note If you need to display jstack information, make sure that the Detail parameter in the request is set to true.
  • false: does not display jstack information. This is the default value. The Jstack parameter is empty in the response.

Response parameters

Parameter Type Example Description
Data Struct

The returned query results.

ConnectionSet Array of ConnectionDo

The information about online consumers in the consumer group.

ConnectionDo
ClientAddr String 30.5.121.**

The IP address and port number of the consumer.

ClientId String 30.5.121.**@25560#-1999745829#-1737591554#458773089270275

The ID of the consumer.

Language String JAVA

The programming language in which the consumer was developed.

RemoteIP String 42.120.74.**

The host IP address or public IP address of the consumer.

Version String V4_3_6_SNAPSHOT

The version of the consumer.

ConsumeModel String CLUSTERING

The consumption mode. Valid values:

  • CLUSTERING: clustering consumption
  • BROADCASTING: broadcasting consumption

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

ConsumeTps Float 0

The total consumption TPS.

ConsumerConnectionInfoList Array of ConsumerConnectionInfoDo

The detailed information about online consumers in the consumer group, including the jstack information and consumption response time (RT). If you need to query more information, make sure that the Detail parameter in the request is set to true. Otherwise, the returned value is empty.

ConsumerConnectionInfoDo
ClientId String 30.5.**.**@25560#-1999745829#-1737591554#458773089270275

The ID of the consumer.

Connection String **

The connection information.

ConsumeModel String CLUSTERING

The consumption mode. Valid values:

  • CLUSTERING: clustering consumption
  • BROADCASTING: broadcasting consumption

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

ConsumeType String PUSH

The way in which the consumer consumes messages. Valid values:

  • PUSH: The Message Queue for Apache RocketMQ broker pushes messages to the consumer.
  • PULL: The consumer pulls messages from the Message Queue for Apache RocketMQ broker.
Jstack Array of ThreadTrackDo

The jstack information. If you need to query jstack information, make sure that the NeedJstack parameter in the request is set to true. Otherwise, the returned value is empty.

ThreadTrackDo
Thread String ConsumeMessageThread_0

The name of the thread.

TrackList List TID: 52 STATE: WAITING

The detailed jstack information in the form of strings.

Language String JAVA

The programming language in which the consumer was developed.

LastTimeStamp Long 1570701368114

The latest consumption time.

RunningDataList Array of ConsumerRunningDataDo

The real-time statistics.

ConsumerRunningDataDo
FailedCountPerHour Long 0

The number of messages that failed to be consumed per hour.

FailedTps Float 0

The TPS of message consumption failures.

GroupId String 0

The group ID of the consumer.

OkTps Float 0

The TPS of successful message consumption.

Rt Float 0

The consumption RT. Unit: milliseconds.

Topic String test-mq_topic

The name of the topic to which the consumer group has subscribed.

StartTimeStamp Long 1570701361528

The timestamp when the consumption started.

SubscriptionSet Array of SubscriptionData

The information about subscriptions.

SubscriptionData
SubString String *

The subscription string of the topic.

SubVersion Long 1570701364301

The subscription version. The value is automatically incremented and of the LONG type.

TagsSet List ff

The information about the tags to which the consumer group has subscribed.

Topic String test-mq_topic

The name of the topic to which the consumer group has subscribed.

ThreadCount Integer 20

The number of consumption threads used by the consumer.

Version String V4_3_6

The version of the consumer.

DelayTime Long 100857

The consumption latency of the consumer group.

DetailInTopicList Array of DetailInTopicDo

The consumption status of topics. If you need to query more information, make sure that the Detail parameter in the request is set to true. Otherwise, the returned value is empty.

DetailInTopicDo
DelayTime Long 0

The consumption latency of the consumer group.

LastTimestamp Long 1570701259403

The latest consumption time.

Topic String test-mq_topic

The name of the topic.

TotalDiff Long 0

The number of accumulated messages in the topic.

InstanceId String MQ_INST_111111111111_DOxxxxxx

The ID of the instance.

LastTimestamp Long 1566883844954

The latest consumption time.

Online Boolean true

Indicates whether the consumer group is online.

RebalanceOK Boolean true

Indicates whether load balancing is normal. Valid values:

  • true: normal
  • false: abnormal
SubscriptionSame Boolean true

Indicates whether the subscriptions are consistent in the consumer group.

TotalDiff Long 197

The total number of accumulated messages in the cluster.

RequestId String 10EDC518-10E7-4B34-92FB-171235FA****

The ID of the request. This is a common parameter. Each request has a unique ID. This facilitates troubleshooting.

Examples

Sample requests

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

Sample success responses

XML format

<OnsConsumerStatusResponse>
  <data>
        <connectionSet>
              <bizVersion>V4_3_6</bizVersion>
              <clientAddr>30.5.***.*</clientAddr>
              <clientId>30.5.***.*@97730#-1999745829#-1737591554#729272961762836</clientId>
              <language>JAVA</language>
              <version>V4_3_6</version>
        </connectionSet>
        <consumeModel>CLUSTERING</consumeModel>
        <consumeTps>0</consumeTps>
        <consumerConnectionInfoList>
              <bizVersion>V4_3_6</bizVersion>
              <clientId>30.5.***.*@97730#-1999745829#-1737591554#729272961762836</clientId>
              <consumeType>PUSH</consumeType>
              <jstack>
                    <thread>ConsumeMessageThread_4</thread>
                    <trackList>TID: 44 STATE: WAITING</trackList>
                    <trackList>sun.misc.Unsafe.park(Native Method)</trackList>
                    <trackList>java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)</trackList>
                    <trackList>java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)</trackList>
                    <trackList>java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)</trackList>
                    <trackList>java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)</trackList>
                    <trackList>java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)</trackList>
                    <trackList>java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)</trackList>
                    <trackList>java.lang.Thread.run(Thread.java:748)</trackList>
              </jstack>
              <language>JAVA</language>
              <lastTimeStamp>1570701368114</lastTimeStamp>
              <runningDataList>
                    <failedCountPerHour>0</failedCountPerHour>
                    <failedTps>0</failedTps>
                    <okTps>0</okTps>
                    <rt>0</rt>
                    <topic>test-mq_topic</topic>
              </runningDataList>
              <startTimeStamp>1570701361528</startTimeStamp>
              <subscriptionSet>
                    <subString>*</subString>
                    <subVersion>1570701364301</subVersion>
                    <topic>test-mq_topic</topic>
              </subscriptionSet>
              <threadCount>20</threadCount>
              <version>V4_3_6</version>
        </consumerConnectionInfoList>
        <delayTime>0</delayTime>
        <detailInTopicList>
              <delayTime>0</delayTime>
              <lastTimestamp>1570701259403</lastTimestamp>
              <topic>test-mq_topic</topic>
              <totalDiff>0</totalDiff>
        </detailInTopicList>
        <instanceId>MQ_INST_111111111111_DOxxxxxx</instanceId>
        <lastTimestamp>1570701368114</lastTimestamp>
        <online>true</online>
        <rebalanceOK>true</rebalanceOK>
        <subscriptionSame>true</subscriptionSame>
        <totalDiff>0</totalDiff>
  </data>
  <requestId>10EDC518-10E7-4B34-92FB-171235FA****</requestId>
</OnsConsumerStatusResponse>

JSON format

{
  "data": {
    "connectionSet": [
      {
        "bizVersion": "V4_3_6",
        "clientAddr": "30.5.***.*",
        "clientId": "30.5.***.*@97730#-1999745829#-1737591554#729272961762836",
        "language": "JAVA",
        "version": "V4_3_6"
      }
    ],
    "consumeModel": "CLUSTERING",
    "consumeTps": 0,
    "consumerConnectionInfoList": [
      {
        "bizVersion": "V4_3_6",
        "clientId": "30.5.***.*@97730#-1999745829#-1737591554#729272961762836",
        "consumeType": "PUSH",
        "jstack": [
          {
            "thread": "ConsumeMessageThread_1",
            "trackList": [
              "TID: 44 STATE: WAITING",
              "sun.misc.Unsafe.park(Native Method)",
              "java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)",
              "java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)",
              "java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)",
              "java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)",
              "java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)",
              "java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)",
              "java.lang.Thread.run(Thread.java:748)"
            ]
          }
        ],
        "language": "JAVA",
        "lastTimeStamp": 1570701368114,
        "runningDataList": [
          {
            "failedCountPerHour": 0,
            "failedTps": 0,
            "okTps": 0,
            "rt": 0,
            "topic": "test-mq_topic"
          }
        ],
        "startTimeStamp": 1570701361528,
        "subscriptionSet": [
          {
            "subString": "*",
            "subVersion": 1570701364301,
            "tagsSet": [],
            "topic": "test-mq_topic"
          }
        ],
        "threadCount": 20,
        "version": "V4_3_6"
      }
    ],
    "delayTime": 0,
    "detailInTopicList": [
      {
        "delayTime": 0,
        "lastTimestamp": 1570701259403,
        "topic": "test-mq_topic",
        "totalDiff": 0
      }
    ],
    "instanceId": "MQ_INST_111111111111_DOxxxxxx",
    "lastTimestamp": 1570701368114,
    "online": true,
    "rebalanceOK": true,
    "subscriptionSame": true,
    "totalDiff": 0
  },
  "requestId": "10EDC518-10E7-4B34-92FB-171235FA****"
}

Error codes

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

Operation in the Message Queue for Apache RocketMQ console

In addition to calling the OnsConsumerStatus API operation, you can also query the consumption details of a consumer group in the Message Queue for Apache RocketMQ console. For more information about the operation in the console, see View the status of consumers.