You can call this operation to create a trace query task based on a specified topic name and message key to obtain the ID of the query task.

If you have recorded a message key and need to query the delivery trace of a message based on the message key, you can call the OnsTraceQueryByMsgKey operation to create a query task. After the task ID is returned, the service provider can call the OnsTraceGetResult operation to query the trace query results based on the task ID. For more information about the OnsTraceGetResult operation, see OnsTraceGetResult.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTraceQueryByMsgKey

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

BeginTime Long Yes 1570852800

The beginning of the time range to query.

EndTime Long Yes 1570968000

The end of the time range to query.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance corresponding to the topic of the message that you want to query.

MsgKey String Yes ORDERID_100

The key of the message that you want to query.

Topic String Yes test

The topic of the message that you want to query.

Response parameters

Parameter Type Example Description
QueryId String 272967562652883649157096685****

The ID of the query task. You can call the OnsTraceGetResult operation to query detailed results based on the task ID.

RequestId String F8654231-122A-4DBD-801F-38E3553851A8

The ID of the request. This is a common parameter.

Examples

Sample requests

http(s)://[Endpoint]/? Action=OnsTraceQueryByMsgKey
&BeginTime=1570852800
&EndTime=1570968000
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&MsgKey=ORDERID_100
&Topic=test
&<Common request parameters>

Sample success responses

XML format

<OnsTraceQueryByMsgKeyResponse>
  <RequestId>F8654231-122A-4DBD-801F-38E3553851A8</RequestId>
  <QueryId>272967562652883649157096685****</QueryId>
</OnsTraceQueryByMsgKeyResponse>

JSON format

{
	"RequestId": "F8654231-122A-4DBD-801F-38E3553851A8",
    "QueryId": "272967562652883649157096685****"
}

Error codes

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