Queries the delivery 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 clients that subscribe to the message and the time when the message is delivered. This operation helps you locate the problem and identify the cause of the problem.

Billing

Each successful call to the QueryMqttTraceMessageSubscribe 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

Parameter Type Required Example Description
Action String Yes QueryMqttTraceMessageSubscribe

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

MqttRegionId String Yes cn-hangzhou

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

InstanceId String Yes mqtt-cn-i7m26mf****

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

ClientId String Yes GID_test@@@consumer

The ID of the client that subscribes to the message. If this parameter is not specified, the IDs of all the clients that subscribe to the message are returned.

MsgId String Yes AC1EC1B33D5978308DB17F3245E4****

The ID of the message.

EndTime Long Yes 1618646400000

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.

BeginTime Long Yes 1621936800000

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.

CurrentPage Integer Yes 1

The number of the page to return. Pages start from page 1. If the input parameter value is greater than the total number of pages, the returned result is empty.

PageSize Integer Yes 5

The number of entries to return on each page. Valid values: 1 to 100.

Reverse Boolean Yes false

Specifies whether the returned results are displayed in reverse chronological order. Valid values:

  • true: The returned results are displayed in reverse order of the time when the message is delivered. This means that the last consumed message is displayed as the first entry and that the earliest consumed message is displayed as the last entry.
  • false: The returned results are displayed in order of the time when the message is delivered. This means that the earliest consumed message is displayed as the first entry and that the last consumed message is displayed as the last entry.

If this parameter is not specified, the returned results are displayed in order of the time when the message is delivered.

Response parameters

Parameter Type Example Description
RequestId String 4E685844-ADAF-4D85-9EAC-F9471E8C****

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

Total Long 2

The total number of delivery traces returned.

CurrentPage Integer 1

The page number of the returned page.

PageSize Integer 5

The number of entries to return on each page.

MessageTraceLists Array of MessageTraceLists

The delivery traces of the message queried.

Action String sub

The action on the message. Valid values:

  • sub: The Message Queue for MQTT client subscribes to the message.
  • push_offline: The Message Queue for MQTT broker pushes the offline message to the Message Queue for MQTT client.
ActionCode String mqtt.trace.action.msg.sub

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

  • mqtt.trace.action.msg.sub: This parameter value is returned if the value of the Action parameter is sub.
  • mmqtt.trace.action.msg.push.offline: This parameter value is returned if the value of the Action parameter is push_offline.
ActionInfo String Push To Mqtt Client

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

  • Push To Mqtt Client: This parameter value is returned if the value of the Action parameter is sub.
  • Push Offline Msg To Mqtt Client: This parameter value is returned if the value of the Action parameter is push_offline.
ClientId String GID_test@@@consumer

The ID of the client that subscribes the message.

MsgId String AC1EC1B33D5978308DB17F3245E4****

The ID of the message.

Time String 2021-05-25 16:46:41.274

The time when the message was delivered.

Examples

Sample requests

http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=QueryMqttTraceMessageSubscribe
&MqttRegionId=cn-hangzhou
&InstanceId=mqtt-cn-i7m26mf****
&ClientId=GID_test@@@consumer
&MsgId=AC1EC1B33D5978308DB17F3245E4****
&EndTime=1618646400000
&BeginTime=1621936800000
&CurrentPage=1
&PageSize=5
&Reverse=false
&<Common request parameters>

Sample success responses

XML format

<QueryMqttTraceMessageSubscribeResponse>
    <MessageTraceLists>
        <Action>sub</Action>
        <ActionCode>mqtt.trace.action.msg.sub</ActionCode>
        <ClientId>GID_test@@@consumer</ClientId>
        <ActionInfo>Push To Mqtt Client</ActionInfo>
        <Time>2021-05-25 16:46:41.274 </Time>
        <MsgId>AC1EC1B33D5978308DB17F3245E4****</MsgId>
    </MessageTraceLists>
    <MessageTraceLists>
        <Action>sub</Action>
        <ActionCode>mqtt.trace.action.msg.sub</ActionCode>
        <ClientId>GID_test@@@consumer2</ClientId>
        <ActionInfo>Push To Mqtt Client</ActionInfo>
        <Time>2021-05-25 16:46:41.247 </Time>
        <MsgId>AC1EC1B33D5978308DB17F3245E4****</MsgId>
    </MessageTraceLists>
    <RequestId>4E685844-ADAF-4D85-9EAC-F9471E8C****</RequestId>
    <PageSize>5</PageSize>
    <CurrentPage>1</CurrentPage>
    <Total>2</Total>
</QueryMqttTraceMessageSubscribeResponse>

JSON format

{
        "MessageTraceLists": [
            {
                "Action": "sub",
                "ActionCode": "mqtt.trace.action.msg.sub",
                "ClientId": "GID_test@@@consumer",
                "ActionInfo": "Push To Mqtt Client",
                "Time": "2021-05-25 16:46:41.274",
                "MsgId": "AC1EC1B33D5978308DB17F3245E4****"
            },
            {
                "Action": "sub",
                "ActionCode": "mqtt.trace.action.msg.sub",
                "ClientId": "GID_test@@@consumer2",
                "ActionInfo": "Push To Mqtt Client",
                "Time": "2021-05-25 16:46:41.247",
                "MsgId": "AC1EC1B33D5978308DB17F3245E4****"
            }
        ],
        "RequestId": "4E685844-ADAF-4D85-9EAC-F9471E8C****",
        "PageSize": 5,
        "CurrentPage": 1,
        "Total": 2
}

Error codes

HttpCode Error code Error message Description
404 ApiNotSupport The specified API operation is not supported. The error message returned because the API operation is not supported.
500 SystemOverFlow An 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 Message Queue for MQTT console

In addition to calling the QueryMqttTraceMessageSubscribe operation, you can also view the delivery traces of a message in the Message Queue for MQTT console. For more information, see Query message traces.