Queries the details of a message trace based on a specified query task ID.

Usage notes

  • Before you call this operation to query the details of the trace of a message, you must create a task to query the trace of the message based on the message ID or message key and obtains the task ID. Then, you can call this operation to query the details of the message trace based on the task ID. You can call the OnsTraceQueryByMsgId operation or the OnsTraceQueryByMsgKey operation to create a task to query the trace of the message and obtain the task ID from the QueryId response parameter.
  • A trace query task is time-consuming. If you call this operation to query the details immediately after you create a trace query task, the results may be empty. In this case, we recommend that you try again later.

Request limit

Each Alibaba Cloud account can call this operation up to 10 times per second. If the number of requests that you send to call this operation within 1 second reaches the request limit, new requests fail. This may interrupt your business. For information about the request limit of each operation, see API rate limits.

Authorization

By default, only Alibaba Cloud accounts can call this operation. A Resource Access Management (RAM) user can call this operation only after the RAM user is granted the required permissions. The following table describes the permissions that must be granted to a RAM user to call this operation. For information about how to grant permissions, Policies and examples.

API

Action

Resource

OnsTraceGetResult

mq:QueryInstanceBaseInfo

acs:mq:*:*:{instanceId}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTraceGetResult

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

QueryId String Yes 272967562652883649157096685****

The ID of the task that was created to query the trace of the message.

Response parameters

Parameter Type Example Description
RequestId String 84EE24D2-851F-40D6-B99E-4D6AB909****

The ID of the request. The system generates a unique ID for each request. You can troubleshoot issues based on the request ID.

TraceData Object

The details of the message trace.

Status String finish

The status of the task. Valid values:

  • finish: The task is complete.
  • working: The task is in progress.
  • removed: The task is deleted.
MsgKey String ORDERID_100

The key of the message that is queried.

UpdateTime Long 1570966877000

The most recent point in time when the task was updated.

CreateTime Long 1570966857000

The point in time when the task was created.

Topic String test

The topic in which the message is stored.

UserId String 27296756265288****

The ID of the user who created the task.

InstanceId String MQ_INST_111111111111_DOxxxxxx

The ID of the instance that contains the message.

MsgId String 1E05791C117818B4AAC23B1BB0CE****

The ID of the message that is queried.

TraceList Array of TraceMapDo

The details of the message trace.

TraceMapDo
Status String SEND_SUCCESS

Indicates whether the message is sent. Valid values:

  • SEND_SUCCESS: The message is sent.
  • SEND_FAILED: The message failed to be sent.
  • SEND_ROLLBACK: The message is a transactional message and is rolled back.
  • SEND_UNKNOWN: The message is a transactional message and is not committed.
  • SEND_DELAY: The message is a scheduled or delayed message and is waiting to be sent at the specified point in time.
MsgKey String ORDERID_100

The key of the message.

PubTime Long 1570850870478

The point in time when the message was sent.

SubList Array of SubMapDo

The consumption traces of the message.

SubMapDo
ClientList Array of SubClientInfoDo

The information about message consumption by consumers in the group.

SubClientInfoDo
Status String CONSUME_SUCCESS

Indicates whether the message is consumed. Valid values:

  • CONSUME_FAILED: The message failed to be consumed.
  • CONSUME_SUCCESS: The message is consumed.
  • CONSUME_NOT_RETURN: No responses are returned.
  • SEND_UNKNOWN: The message is a transactional message and is not committed.
  • SEND_DELAY: The message is a scheduled or delayed message and is waiting to be consumed at the specified point in time.
SubTime Long 1570851590511

The earliest point in time when the message was consumed.

ReconsumeTimes Integer 1

The number of attempts that the Message Queue for Apache RocketMQ broker tried to send the message to the consumer.

SubGroupName String GID_test

The ID of the group that contains the consumer.

ClientHost String 30.5.**.**

The address of the consumer.

CostTime Integer 43

The period of time that the system took to consume the message. Unit: milliseconds.

FailCount Integer 0

The number of consumption failures.

SubGroupName String GID_test

The ID of the consumer group.

SuccessCount Integer 1

The number of successful consumptions.

Topic String test

The topic in which the message is stored.

CostTime Integer 24

The period of time that the system took to send the message. Unit: milliseconds.

Tag String TagA

The tag of the message.

MsgId String 0BC1F01800002A9F000000531246****

The ID of the message.

PubGroupName String GID_test

The ID of the group that contains the producer.

BornHost String 30.5.**.**

The address of the producer that generated the message.

QueryId String 272967562652883649157096685****

The ID of the task.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=OnsTraceGetResult
&QueryId=272967562652883649157096685****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<OnsTraceGetResultResponse>
<TraceData>
    <MsgId>1E05791C117818B4AAC23B1BB0CE****</MsgId>
    <Status>finish</Status>
    <TraceList>
        <TraceMapDo>
            <BornHost>30.5.**.**</BornHost>
            <MsgId>0BC1F01800002A9F000000531246****</MsgId>
            <Status>SEND_SUCCESS</Status>
            <CostTime>24</CostTime>
            <PubTime>1570850870478</PubTime>
            <Tag>TagA</Tag>
            <Topic>test</Topic>
            <MsgKey>ORDERID_100</MsgKey>
            <PubGroupName>GID_test</PubGroupName>
            <SubList>
                <SubMapDo>
                    <ClientList>
                        <SubClientInfoDo>
                            <Status>CONSUME_SUCCESS</Status>
                            <CostTime>43</CostTime>
                            <ClientHost>30.5.**.**</ClientHost>
                            <ReconsumeTimes>1</ReconsumeTimes>
                            <SubTime>1570851590511</SubTime>
                            <SubGroupName>GID_test</SubGroupName>
                        </SubClientInfoDo>
                    </ClientList>
                    <SuccessCount>1</SuccessCount>
                    <FailCount>0</FailCount>
                    <SubGroupName>GID_test</SubGroupName>
                </SubMapDo>
            </SubList>
        </TraceMapDo>
    </TraceList>
    <CreateTime>1570966857000</CreateTime>
    <InstanceId>MQ_INST_111111111111_DOxxxxxx</InstanceId>
    <Topic>test</Topic>
    <UpdateTime>1570966877000</UpdateTime>
    <QueryId>272967562652883649157096685****</QueryId>
    <UserId>27296756265288****</UserId>
</TraceData>
<RequestId>84EE24D2-851F-40D6-B99E-4D6AB909****</RequestId>
</OnsTraceGetResultResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "TraceData" : {
    "MsgId" : "1E05791C117818B4AAC23B1BB0CE****",
    "Status" : "finish",
    "TraceList" : {
      "TraceMapDo" : [ {
        "BornHost" : "30.5.**.**",
        "MsgId" : "0BC1F01800002A9F000000531246****",
        "Status" : "SEND_SUCCESS",
        "CostTime" : 24,
        "PubTime" : 1570850870478,
        "Tag" : "TagA",
        "Topic" : "test",
        "MsgKey" : "ORDERID_100",
        "PubGroupName" : "GID_test",
        "SubList" : {
          "SubMapDo" : [ {
            "ClientList" : {
              "SubClientInfoDo" : [ {
                "Status" : "CONSUME_SUCCESS",
                "CostTime" : 43,
                "ClientHost" : "30.5.**.**",
                "ReconsumeTimes" : 1,
                "SubTime" : 1570851590511,
                "SubGroupName" : "GID_test"
              } ]
            },
            "SuccessCount" : 1,
            "FailCount" : 0,
            "SubGroupName" : "GID_test"
          } ]
        }
      } ]
    },
    "CreateTime" : 1570966857000,
    "InstanceId" : "MQ_INST_111111111111_DOxxxxxx",
    "Topic" : "test",
    "UpdateTime" : 1570966877000,
    "QueryId" : "272967562652883649157096685****",
    "UserId" : "27296756265288****"
  },
  "RequestId" : "84EE24D2-851F-40D6-B99E-4D6AB909****"
}

Error codes

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

Query the trace of a message in the console

You can also query the trace of a message in the Message Queue for Apache RocketMQ console. For more information, see Query a message trace.