All Products
Search
Document Center

ApsaraMQ for RocketMQ:OnsTraceGetResult

Last Updated:Dec 12, 2025

Fetches the results of a message trace query task using its task ID.

Operation description

Important Alibaba Cloud OpenAPI is a management API. Use it to manage and query resources for Alibaba Cloud services. Integrate this API for management purposes only. Do not use this API on the core data link for sending and receiving messages because this can create threats to your data link.
  • After you create a message trace query task by calling the OnsTraceQueryByMsgId or OnsTraceQueryByMsgKey operation, you receive a task ID. You can then call this operation to retrieve the details of the message trace. The task ID is the QueryId that is returned by the creation operation.

  • Message trace query tasks are time-consuming. If you call this operation immediately after creating a task, the query may return an empty result. If this occurs, wait for a short period and then retry the call.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

mq:GetTraceResult

get

*Topic

acs:mq:{#regionId}:{#accountId}:{#InstanceId}%{#TopicName}

*Topic

acs:mq:{#regionId}:{#accountId}:{#TopicName}

None
  • mq:QueryInstanceBaseInfo

Request parameters

Parameter

Type

Required

Description

Example

QueryId

string

Yes

The ID of the task for which to fetch the message trace query results.

272967562652883649157096685****

InstanceId

string

No

The ID of the instance that contains the message you want to query.

MQ_INST_111111111111_DOxxxxxx

Topic

string

No

The topic of the message you want to query.

test

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request. This is a common parameter. Each request has a unique ID that you can use to troubleshoot issues.

84EE24D2-851F-40D6-B99E-4D6AB909****

TraceData

object

The details of the query task results.

Status

string

The result of the query task. Valid values:

  • finish: The query is complete.

  • working: The query is in progress.

  • removed: The task is deleted.

finish

MsgKey

string

The message key that corresponds to the query task.

ORDERID_100

UpdateTime

integer

The last update time of the query task.

1570966877000

CreateTime

integer

The creation time of the query task.

1570966857000

Topic

string

The topic of the query task.

test

UserId

string

The ID of the user who initiated the query.

27296756265288****

InstanceId

string

The instance ID.

MQ_INST_111111111111_DOxxxxxx

MsgId

string

The message ID that corresponds to the query task.

1E05791C117818B4AAC23B1BB0CE****

TraceList

object

TraceMapDo

array<object>

The list of matched message traces for the query task.

array<object>

Status

string

The sending status. Valid values:

  • SEND_SUCCESS: The message was sent successfully.

  • SEND_FAILED: The message failed to be sent.

  • SEND_ROLLBACK: The transactional message was rolled back.

  • SEND_UNKNOWN: The transactional message was not committed.

  • SEND_DELAY: The scheduled or delayed message is waiting to be sent.

SEND_SUCCESS

MsgKey

string

The message key.

ORDERID_100

PubTime

integer

The time when the message was sent.

1570850870478

SubList

object

SubMapDo

array<object>

The list of consumption traces for the message.

array<object>

ClientList

object

SubClientInfoDo

array<object>

The list of consumption records for the client that belongs to the group ID.

object

Status

string

The consumption status. Valid values:

  • CONSUME_FAILED: The message failed to be consumed.

  • CONSUME_SUCCESS: The message was consumed successfully.

  • CONSUME_NOT_RETURN: The consumption result was not returned.

  • SEND_UNKNOWN: The transactional message was not committed.

  • SEND_DELAY: The scheduled or delayed message is waiting to be sent.

CONSUME_SUCCESS

SubTime

integer

The UNIX timestamp for when the consumption started.

1570851590511

ReconsumeTimes

integer

The number of delivery attempts for this consumption.

1

SubGroupName

string

The group ID to which the client belongs.

GID_test

ClientHost

string

The address of the consumer client.

30.5.**.**

CostTime

integer

The time taken for this consumption, in milliseconds.

43

FailCount

integer

The number of consumption failures for the group ID.

0

SubGroupName

string

The group ID of the consumer.

GID_test

SuccessCount

integer

The number of successful consumptions for the group ID.

1

Topic

string

The topic of the message.

test

CostTime

integer

The time taken to send the message, in milliseconds.

24

Tag

string

The message tag.

TagA

MsgId

string

The message ID.

0BC1F01800002A9F000000531246****

PubGroupName

string

The group ID configured on the producer client.

GID_test

BornHost

string

The address of the producer client.

30.5.**.**

QueryId

string

The ID of the query task.

272967562652883649157096685****

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.