edit-icon download-icon

Query accumulation

Last Updated: Dec 21, 2018

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


This interface queries the message accumulation of a specified Consumer ID and retrieves the number of not consumed messages and consumption latency.

This interface not only queries the message accumulation amount of all Topics of the specified Consumer ID, but also queries the message accumulation amount of each Topic.

Note: Use the Query consumer status interface to query the consumption information about each online Consumer instance of a specific Consumer ID.


Consumer accumulate query is used when you need to understand the consumption progress of the Consumer ID in the production environment, and to have a rough idea about the message consumption and latency.

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. False by default.

Response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
Data Data The consumption accumulation of the specified Consumer

Data structure

Member Type Description
OnLine Boolean Indicates whether any Consumer instance of a specific Consumer ID is online. The status of the Consumer ID is online once it has one online Consumer instance.
TotalDiff Long The total number of accumulated messages of all Topics to which the current Consumer ID subscribes
ConsumeTps Float TPS of messages sent and received by the Consumer instance cluster of a specific Consumer ID
LastTimestamp Long The production time of the message that is last consumed by the Consumer instance cluster of a specific Consumer ID
DelayTime Long The maximum consumption latency for the Consumer instance cluster of a specific Consumer ID
DetailInTopicList List(OnsConsumerAccumulateResponse.Data.DetailInTopicDo) Details of each Topic

DetailInTopicList data structure

Member Type Description
Topic String The Topic name
TotalDiff Long The consumption accumulation of the current Topic
LastTimestamp Long The production time of the message that is last consumed in the Topic
TotalDiff Long The consumption latency of the current Topic
  • OnsConsumerStatus: queries the consumer status details
  • OnsConsumerConnection: queries the consumer connection
  • OnsResetOffset: clears the consumption accumulation


  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. OnsConsumerAccumulateRequest request = new OnsConsumerAccumulateRequest();
  19. // request.setCluster("taobaodaily");
  20. /**
  21. *OnsRegionId refers to the resource of the region of MQ required to be accessed by API.
  22. *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.
  23. */
  24. request.setOnsRegionId("daily");
  25. request.setPreventCache(System.currentTimeMillis());
  26. request.setAcceptFormat(FormatType.JSON);
  27. request.setDetail(true);
  28. request.setConsumerId("RTDSQ_1013_GROUP");
  29. try {
  30. OnsConsumerAccumulateResponse response=iAcsClient.getAcsResponse(request);
  31. OnsConsumerAccumulateResponse.Data data =response.getData();
  32. System.out.println(data.getOnline()+" "+data.getTotalDiff()+" "+data.getConsumeTps()+" "
  33. +data.getDelayTime()+" "+data.getLastTimestamp());
  34. for (OnsConsumerAccumulateResponse.Data.DetailInTopicDo detailInTopicDo:data.getDetailInTopicList()){
  35. System.out.println(detailInTopicDo.getTopic()+" "
  36. +detailInTopicDo.getTotalDiff()+" "
  37. +detailInTopicDo.getLastTimestamp()+" "+detailInTopicDo.getDelayTime());
  38. }
  39. } catch (ServerException e) {
  40. e.printStackTrace();
  41. } catch (ClientException e) {
  42. e.printStackTrace();
  43. }
  44. }
Thank you! We've received your feedback.