edit-icon download-icon

Query consumer status

Last Updated: Apr 08, 2018

This interface is exclusive for MQ Platinum edition users. For more information, go to Platinum Edition Purchase Page.


This interface queries the detailed status data of a specified Consumer ID, including subscription relation checking, consumption TPS count, server load balancer status, consumer connection, and so on.


This interface identifies the detailed status of the Consumer ID. It’s called when you need to troubleshoot the exceptions after having a rough idea of the consumption accumulation and client connection status. It tells if the subscription relations of a specified Consumer Group (CID) are consistent, if the server load balancer is normal, and the Jstack information of online clients.

Note: this interface calls a number of backend interfaces to aggregate data, and the query speed is relatively slow, so it’s not recommended to call it frequently.

Request parameters

Name Type Required Description
OnsRegionId String Yes The region where the queried MQ is currently located. It can be obtained through the OnsRegionList method.
OnsPlatform String No The source of the request, which by default is POP platform.
PreventCache Long Yes It’s used for CSRF verification. Set it to the current system time.
ConsumerId String Yes The consumer CID to be queried
Detail Boolean No If to query detailed information
NeedJstack Boolean No If to print Jstack information

Response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
Data ConsumerStatusDo Query result

ConsumerStatusDo data structure

Member Type Description
Online Boolean If it’s online
TotalDiff Long The total consumption accumulation of a cluster
ConsumeTps Long TPS of the total consumption
LastTimestamp Long The last update time
DelayTime Long The delay time
ConsumeModel Long Consumption model
SubscriptionSame Boolean If the subscription relation is the same
RebalanceOK Boolean If the client Rebalance is normal
ConnectionSet List(ConnectionDo) The information of the current online client of the cluster
DetailInTopicList List(DetailInTopicDo) The consumption conditions of each Topic
ConsumerConnectionInfoList List(ConsumerConnectionInfoDo) The detailed information of the online client of the cluster, including Jstack, consumed RT time, and so on.

ConnectionDo data structure

Member Type Description
ClientId String ID of a consumption instance
ClientAddr String Address and port of the consumption instance
Language String Language of the consumer
Version String The consumer version

DetailInTopicDo data structure

Member Type Description
Topic String The Topic name
TotalDiff Long The total number of consumption accumulations of the Topic
LastTimestamp Long The last update time
DelayTime Long The delay time

ConsumerConnectionInfoDo data structure

Member Type Description
ClientId String ID of a consumption instance
Connection String Connection information
Language String Language of the client
Version String Version number of the client
ConsumeModel String The consume model, including Cluster and Broadcast.
ConsumeType String Where to consume
ThreadCount Integer The number of consumed threads
StartTimeStamp Long Start time
LastTimeStamp Long The last update time
SubscriptionSet List(SubscriptionData) The set of subscription relations
RunningDataList List(ConsumerRunningDataDo) Real-time status counting
Jstack List(ThreadTrackDo) Jstack stack information

SubscriptionData data structure

Member Type Description
Topic String The name of the subscribed Topic
SubString String The expression of the subcategory Tag subscribing the Topic.
SubVersion Long The version number of the subscription relation, which is incremental Long type.
TagsSet List(String) The set of subscribed Tags.

ConsumerRunningDataDo data structure

Member Type Description
ConsumerId String The Consumer ID name of the subscriber
Topic String The name of the subscribed Topic
Rt Float The RT consumption time in ms
OkTps Float TPS counting for messages consumed successfully
FailedTps Float TPS counting for messages failed to consume
FailedCountPerHour Long Count of messages failed to consume per hour

ThreadTrackDo data structure

Member Type Description
Thread String The thread name
TrackList List(String) Jstack stack information string
  • OnsConsumerAccumulate: queries the consumption accumulation
  • OnsConsumerConnection: queries the client connection of a consumer


  1. public static void main(String []args) {
  2. String regionId = "cn-hangzhou";
  3. String accessKey = "XXXXXXXXXXXXXXXXX";
  4. String secretKey = "XXXXXXXXXXXXXXXXX";
  5. String endPointName ="cn-hangzhou";
  6. String productName ="Ons";
  7. String domain ="ons.cn-hangzhou.aliyuncs.com";
  8. /**
  9. *Select Region based on the region you will access, and set the corresponding access point.
  10. */
  11. try {
  12. DefaultProfile.addEndpoint(endPointNameregionIdproductNamedomain);
  13. } catch (ClientException e) {
  14. e.printStackTrace();
  15. }
  16. IClientProfile profile= DefaultProfile.getProfile(regionIdaccessKeysecretKey);
  17. IAcsClient iAcsClient= new DefaultAcsClient(profile);
  18. OnsConsumerStatusRequest request = new OnsConsumerStatusRequest();
  19. /**
  20. *OnsRegionId refers to the resource of the region of MQ required to be accessed by API.
  21. *This value must be selected and configured by the list obtained through the OnsRegionList method because OnsRegionId is changing, and cannot be written as a fixed value.
  22. */
  23. request.setOnsRegionId("daily");
  24. request.setPreventCache(System.currentTimeMillis());
  25. request.setAcceptFormat(FormatType.JSON);
  26. request.setConsumerId("CID_Mingduan");
  27. request.setDetail(true);
  28. request.setNeedJstack(false);
  29. try {
  30. OnsConsumerStatusResponse response=iAcsClient.getAcsResponse(request);
  31. OnsConsumerStatusResponse.Data data =response.getData();
  32. List<OnsConsumerStatusResponse.Data.ConnectionDo> connectionDoList = data.getConnectionSet();
  33. List<OnsConsumerStatusResponse.Data.DetailInTopicDo> detailInTopicDoList =data.getDetailInTopicList();
  34. List<OnsConsumerStatusResponse.Data.ConsumerConnectionInfoDo> consumerConnectionInfoDoList =data.getConsumerConnectionInfoList();
  35. System.out.print(data.getOnline()+" "+data.getTotalDiff()+" "+data.getConsumeTps()+" "+
  36. data.getLastTimestamp()+" "+data.getDelayTime()+" "+data.getConsumeModel()+
  37. " "+data.getSubscriptionSame()+" "+data.getRebalanceOK());
  38. } catch (ServerException e) {
  39. e.printStackTrace();
  40. } catch (ClientException e) {
  41. e.printStackTrace();
  42. }
  43. }
Thank you! We've received your feedback.