All Products
Search
Document Center

OnsDLQMessagePageQueryByGroupId

Last Updated: Apr 09, 2019

OnsDLQMessagePageQueryByGroupId

You can call this operation to query all the dead-letter messages in a group in paging mode within a specific period of time by setting a group ID and a time range.

Description

Range query is implemented if you query dead-letter messages by group ID. Query results are displayed on multiple pages to the caller. This is applicable only when no other search criteria (message ID) are available. Note that you must shorten the query time range. Otherwise, problems will be difficult to locate because of excessive number of matching messages.

The following describes the procedure for calling this operation.

  1. Set the group ID, start time, end time, and number of items on each page to query messages in paging mode. If messages are available, the messages on the first page, total number of pages, and query task ID are returned by default.

  2. Obtain the messages by specifying the returned query task ID and current page number.

Request parameters

Name Type Required Description
PreventCache Long Yes The parameter that is used for CSRF verification, which can be set to the current system time. Unit: ms
InstanceId String Yes The ID of the instance for the message that you want to query.
GroupId String Yes The consumer group ID of the message that you want to query.
BeginTime Long Yes The start time of the query range.
EndTime Long Yes The end time of the query range.
TaskId String No The ID of the query task. This is not required for the first query but is required to obtain messages subsequently. You can obtain the ID based on the previously returned result.
CurrentPage Integer Yes The page number, increasing from 1. Maximum value: 50. Do not enter a value larger than the maximum value.
PageSize Integer No The maximum number of messages that is displayed on each page in paging mode. Default value: 20. Minimum value: 5. Maximum value: 50.

Response parameters

Name Type Description
RequestId String A common parameter. Each request has a unique ID.
HelpUrl String A help link.
MsgFoundDo MsgFoundDo The query results.

Fields in MsgFoundDo

Name Type Description
TaskId String The ID returned for the first query task, which is used to obtain messages subsequently.
MaxPageCount Long The maximum number of pages for displaying the query results.
CurrentPage Long The current page number.
Data List(OnsRestMessageDo) A set of messages displayed on the current page, which is the same as the result that is returned for messageGetById.

Examples

Create a query task

  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 a region and set an endpoint.
  10. */
  11. try {
  12. DefaultProfile.addEndpoint(endPointName, regionId, productName, domain);
  13. } catch (ClientException e) {
  14. e.printStackTrace();
  15. }
  16. IClientProfile profile= DefaultProfile.getProfile(regionId, accessKey, secretKey);
  17. IAcsClient iAcsClient= new DefaultAcsClient(profile);
  18. OnsDLQMessagePageQueryByGroupIdRequest request = new OnsDLQMessagePageQueryByGroupIdRequest ();
  19. request.setPreventCache(System.currentTimeMillis());
  20. request.setInstanceId("XXXXX");
  21. request.setGroupId("XXXXX");
  22. request.setBeginTime(System.currentTimeMillis()-24*3600*1000);
  23. request.setEndTime(System.currentTimeMillis());
  24. request.setCurrentPage(1);
  25. request.setPageSize(20);
  26. try {
  27. OnsDLQMessagePageQueryByGroupIdResponse response = iAcsClient.getAcsResponse(request);
  28. } catch (ServerException e) {
  29. e.printStackTrace();
  30. } catch (ClientException e) {
  31. e.printStackTrace();
  32. }
  33. }

Obtain messages in paging mode

  1. public static void main(String []args) {
  2. String regionId = "cn-hangzhou";
  3. String accessKey = "XXXXX";
  4. String secretKey = "XXXXX";
  5. IClientProfile profile = DefaultProfile.getProfile(regionId, accessKey, secretKey);
  6. IAcsClient iAcsClient = new DefaultAcsClient(profile);
  7. OnsDLQMessagePageQueryByGroupIdRequest request = new OnsDLQMessagePageQueryByGroupIdRequest ();
  8. request.setPreventCache(System.currentTimeMillis());
  9. request.setInstanceId("XXXXXXX");
  10. request.setGroupId("XXXXX");
  11. request.setBeginTime(System.currentTimeMillis()-24*3600*1000);
  12. request.setEndTime(System.currentTimeMillis());
  13. request.setCurrentPage(3);
  14. request.setTaskId("0ADA91A600002A9F000002ADDA8137E8");
  15. try {
  16. OnsDLQMessagePageQueryByGroupIdResponse response = iAcsClient.getAcsResponse(request);
  17. } catch (ServerException e) {
  18. e.printStackTrace();
  19. } catch (ClientException e) {
  20. e.printStackTrace();
  21. }
  22. }