Queries the sending traces of a specified message. If a message is not sent and received as expected, you can call this operation to view the details about the message. For example, you can query the time when the message is published and the client that publishes the message. This operation helps you locate the problem and identify the cause of the problem.

Billing

Each successful call to the QueryMqttTraceMessagePublish operation increases the messaging transaction per second (TPS) by one. Therefore, you are charged for the call. For more information about the billing details, see Billing.

QPS limit

The queries-per-second (QPS) limit on this operation is 500 per user. Throttling is triggered if the number of calls to this operation exceeds this limit. Throttling may affect your business. Therefore, call this operation based on your needs. For more information, see QPS limits.

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

ParameterTypeRequiredExampleDescription
ActionStringYesQueryMqttTraceMessagePublish

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

MqttRegionIdStringYescn-hangzhou

The region ID of the ApsaraMQ for MQTT instance. For more information, see Endpoints.

InstanceIdStringYesmqtt-cn-i7m26mf****

The ID of the ApsaraMQ for MQTT instance. The value must be the instance ID used on the ApsaraMQ for MQTT client. You can view the instance ID in the Basic Information section on the Instance Details page of the instance in the ApsaraMQ for MQTT console.

BeginTimeLongYes1618646400000

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

EndTimeLongYes1621591200000

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

MsgIdStringYesAC1EC0030EAB78308DB16A3EC773****

The ID of the message.

Response parameters

ParameterTypeExampleDescription
RequestIdString69AD5550-BF22-438A-9202-A6E89185****

The ID of the request. This parameter is a common parameter. Each request has a unique ID, which facilitates troubleshooting and problem locating.

MessageTraceListsArray of MessageTraceLists

The traces of the message queried.

ActionStringpub_mqtt

The action on the message. Valid values:

  • pub_mqtt: indicates that a ApsaraMQ for MQTT client sends the message.
  • pub_mq: indicates that a Message Queue for Apache RocketMQ client sends the message.
ActionCodeStringmqtt.trace.action.msg.pub.mqtt

The code returned for the action on the message. Valid values:

  • mqtt.trace.action.msg.pub.mqtt: This parameter value is returned if the value of the Action parameter is pub_mqtt.
  • mqtt.trace.action.msg.pub.mq: This parameter value is returned if the value of the Action parameter is pub_mq.
ActionInfoStringPub From Mqtt Client

The information returned for the action on the message. Valid values:

  • Pub From Mqtt Client: This parameter value is returned if the value of the Action parameter is pub_mqtt.
  • Pub From MQ: This parameter value is returned if the value of the Action parameter is pub_mq.
ClientIdStringGID_test@@@producer

The ID of the client that sends the message.

MsgIdStringAC1EC0030EAB78308DB16A3EC773BD95

The ID of the message.

TimeString2021-05-21 15:08:19.210

The time when the message was sent.

Examples

Sample requests

http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=QueryMqttTraceMessagePublish
&MqttRegionId=cn-hangzhou
&InstanceId=mqtt-cn-i7m26mf****
&BeginTime=1618646400000
&EndTime=1621591200000
&MsgId=AC1EC0030EAB78308DB16A3EC773****
&<Common request parameters>

Sample success responses

XML format

<QueryMqttTraceMessagePublishResponse>
    <MessageTraceLists>
        <Action>pub_mqtt</Action>
        <ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
        <ClientId>GID_test@@@producer</ClientId>
        <Time>2021-05-21 15:08:19.210</Time>
        <ActionInfo>Pub From Mqtt Client</ActionInfo>
        <MsgId>AC1EC0030EAB78308DB16A3EC773****</MsgId>
    </MessageTraceLists>
    <RequestId>69AD5550-BF22-438A-9202-A6E89185****</RequestId>
</QueryMqttTraceMessagePublishResponse>

JSON format

{   
        "MessageTraceLists": {
            "Action": "pub_mqtt",
            "ActionCode": "mqtt.trace.action.msg.pub.mqtt",
            "ClientId": "GID_test@@@producer",
            "Time": "2021-05-21 15:08:19.210",
            "ActionInfo": "Pub From Mqtt Client",
            "MsgId": "AC1EC0030EAB78308DB16A3EC773****"
        },
        "RequestId": "69AD5550-BF22-438A-9202-A6E89185****"
}

Error codes

HttpCodeError codeError messageDescription
404ApiNotSupportThe specified API operation is not supported.The error message returned because the API operation is not supported.
500SystemOverFlowAn error occurred while processing your request. Please try again.The error message returned because throttling is triggered by the system. Try again later.

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

Operations in the ApsaraMQ for MQTT console

In addition to calling the QueryMqttTraceMessagePublish operation, you can also view the sending traces of a message in the ApsaraMQ for MQTT console. For more information, see Query message traces.