edit-icon download-icon

Obtain query result by task ID

Last Updated: Oct 17, 2018

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

OnsTraceGetResultTest interface retrieves the previous trace query result by Task ID of the transferred trace query task.


This interface is used when the business party has created the trace query task by Message ID or Message Key and retrieved the query task ID. If the trace result details need to be retrieved with this Task ID, this interface can be used. Because the message tracing task often takes a while, retrieving results with this interface immediately after the task is created may lead to empty result, in which case, it’s recommended to try again later.

Request parameters

Name Type Required Description
OnsRegionId String Yes It specifies the region to be queried. The value is obtained through the OnsRegionList interface.
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.
QueryId String Yes ID of the task of which the trace query result is to be queried

Response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
TraceData TraceData The result details of the query task

TraceData data structure

Name Type Description
queryId String ID of the query task
userId String ID of the query user
Topic String Topic of the query task
msgId String Message ID corresponding to the query task
msgKey String Message Key corresponding to the query task
status String The status of the query task, including “finish”, “working”, and “removed”.
createTime Long The creation time of the query task
updateTime Long Last update time of the query task
traceList List(TraceMapDo) List of matching traces of the query task

TraceMapDo data structure

Name Type Description
pubTime Long Message sending time
Topic String Topic of the message
pubGroupName String Producer ID configured by the sending client
msgId String Message ID of a message
Tag String Tag of a message
msgKey String Key of a message
bornHost String The client address of the message sender
costTime Integer Sending cost time in milliseconds
status String The sending status, including “SEND_SUCCESS”, “SEND_FAILED”, “SEND_ROLLBACK”, “SEND_UNKNOWN”, and “SEND_DELAY”.
subList List(SubMapDo) List of consumption traces of a message

SubMapDo data structure

Name Type Description
subGroupName String Consumer ID of a consumer
successCount Integer A count of successful consumption of the Consumer ID
failCount Integer A count of failed consumption of the Consumer ID
clientList List(SubClientInfoDo) List of client consumption details of the Consumer ID

SubClientInfoDo data structure

Name Type Description
subGroupName String Consumer ID to which the client belongs
subTime Long The consumption starting time stamp
clientHost String The client address of the consumer client
reconsumeTimes Integer The delivery round of the local consumption
costTime Integer Cost time in milliseconds of the current consumption
status String The consumption status, including “CONSUME_FAILED”, “CONSUME_SUCCESS”, and “CONSUME_NOT_RETURN”.
  • OnsTraceQueryByMsgId: precisely queries the message trace by Message ID.
  • OnsTraceQueryByMsgKey: fuzzily queries the message trace by Message Key.


  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. OnsTraceGetResultRequest request = new OnsTraceGetResultRequest();
  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.setQueryId("XXXXX");
  27. try {
  28. OnsTraceGetResultResponse response = iAcsClient.getAcsResponse(request);
  29. } catch (ServerException e) {
  30. e.printStackTrace();
  31. } catch (ClientException e) {
  32. e.printStackTrace();
  33. }
  34. }
Thank you! We've received your feedback.