Creates a task to query the trace of a message based on the name of the topic in which the message is stored and the message ID. This operation returns the ID of the query task.

Note

If you want to query the trace of a message based on the message ID, you can call this operation to create a query task. After you obtain the task ID, you can call the OnsTraceGetResult operation to query the details of the message trace based on the task ID.

Request limit

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

Authorization

By default, 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, see Policies.

API

Action

Resource in an instance that uses a namespace

Resource in an instance that does not use a namespace

OnsTraceQueryByMsgId

mq:QueryInstanceBaseInfo

mq:QueryTrace

acs:mq:*:*:{instanceId}%{topic}

acs:mq:*:*:{topic}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTraceQueryByMsgId

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

Topic String Yes test

The topic in which the message you want to query is stored.

MsgId String Yes 1E05791C117818B4AAC23B1BB0CE****

The ID of the message that you want to query.

BeginTime Long Yes 1570852800000

The beginning of the time range to query. The value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

EndTime Long Yes 1570968000000

The end of the time range to query. The value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance which contains the specified topic.

Response parameters

Parameter Type Example Description
RequestId String B93332A3-160D-404F-880F-1F8736D1****

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

QueryId String 272967562652883649157096685****

The ID of the query task. You can call the OnsTraceGetResult operation to query the details of the message trace based on the task ID.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=OnsTraceQueryByMsgId
&BeginTime=1570852800000
&EndTime=1570968000000
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&MsgId=1E05791C117818B4AAC23B1BB0CE****
&Topic=test
&<Common request parameters>

Sample success responses

XML format

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

<OnsTraceQueryByMsgIdResponse>
<RequestId>B93332A3-160D-404F-880F-1F8736D1039F</RequestId>
<QueryId>272967562652883649157096685****</QueryId>
</OnsTraceQueryByMsgIdResponse>

JSON format

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

{
  "RequestId" : "B93332A3-160D-404F-880F-1F8736D1039F",
  "QueryId" : "272967562652883649157096685****"
}

Error codes

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

Query the trace of a message in the console

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