调用QueryMqttTraceMessageOfClient查询指定设备的消息收发列表。
计费影响
每成功调用一次QueryMqttTraceMessageOfClient接口,都会计算为一次消息TPS,从而影响您的计费。计费详情,请参见计费说明。
QPS限制
本接口的单用户QPS限制为500次/秒。超过限制,API调用会被限流,这可能会影响您的业务,请合理调用。更多信息,请参见QPS限制。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | QueryMqttTraceMessageOfClient | 系统规定参数。取值:QueryMqttTraceMessageOfClient。 |
MqttRegionId | String | 是 | cn-hangzhou | 云消息队列 MQTT 版实例地域(Region)的ID。请参见服务接入点。 |
InstanceId | String | 是 | mqtt-cn-i7m26mf**** | 云消息队列 MQTT 版实例的ID,一定要和客户端实际使用的实例ID匹配。您可以在控制台实例详情页面的基础信息区域查看。 |
ClientId | String | 是 | GID_test@@@producer | 需要查询消息列表的设备的Client ID。 |
BeginTime | Long | 是 | 1618646400000 | 查询范围的起始时间戳。单位:毫秒。 |
EndTime | Long | 是 | 1621591200000 | 查询范围的终止时间戳。单位:毫秒。 |
CurrentPage | Integer | 是 | 1 | 当前取第几页消息,从1开始递增。若输入参数大于总页数,则返回结果为空。 |
PageSize | Integer | 是 | 5 | 分页查询,每页最多显示的消息数量,最小1条,最多100条。 |
Reverse | Boolean | 否 | false | 返回结果是否倒序显示。取值说明如下:
若不输入,则返回结果默认按照消息发送或消费的时间顺序显示。 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
CurrentPage | Integer | 1 | 当前位于第几页。 |
RequestId | String | B096B9D6-62F3-4567-BB59-58D1362E**** | 公共参数,每个请求的ID都是唯一的,可用于排查和定位问题。 |
PageSize | Integer | 10 | 每页最多显示的消息数量。 |
Total | Long | 5 | 查询到的消息总数。 |
MessageOfClientList | Array of MessageOfClientList | 返回的消息列表。 |
|
Time | String | 2021-05-21 15:08:19.234 | 消息发送的时间或被消费的时间。 |
Action | String | pub_mqtt | 消息动作。取值说明如下:
|
ActionCode | String | mqtt.trace.action.msg.pub.mqtt | 消息动作的返回码。取值说明如下
|
ActionInfo | String | Pub From Mqtt Client | 消息动作的返回信息。取值说明如下:
|
MsgId | String | AC1EC0030EAB78308DB16A3EC773**** | 消息ID,即Message ID。 |
ClientId | String | GID_test@@@producer | 设备的Client ID。 |
示例
请求示例
http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=QueryMqttTraceMessageOfClient
&MqttRegionId=cn-hangzhou
&InstanceId=mqtt-cn-i7m26mf****
&ClientId=GID_test@@@producer
&BeginTime=1618646400000
&EndTime=1621591200000
&CurrentPage=1
&PageSize=5
&<公共请求参数>
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<QueryMqttTraceMessageOfClientResponse>
<RequestId>B096B9D6-62F3-4567-BB59-58D1362E****</RequestId>
<PageSize>10</PageSize>
<CurrentPage>1</CurrentPage>
<Total>5</Total>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.210 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC773****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
</QueryMqttTraceMessageOfClientResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "B096B9D6-62F3-4567-BB59-58D1362E****",
"PageSize" : 10,
"CurrentPage" : 1,
"Total" : 5,
"MessageOfClientList" : [ {
"Action" : "pub_mqtt",
"ActionCode" : "mqtt.trace.action.msg.pub.mqtt",
"ClientId" : "GID_test@@@producer",
"ActionInfo" : "Pub From Mqtt Client",
"Time" : "2021-05-21 15:08:19.210 ",
"MsgId" : "AC1EC0030EAB78308DB16A3EC77****"
}, {
"Action" : "pub_mqtt",
"ActionCode" : "mqtt.trace.action.msg.pub.mqtt",
"ClientId" : "GID_test@@@producer",
"ActionInfo" : "Pub From Mqtt Client",
"Time" : "2021-05-21 15:08:19.234 ",
"MsgId" : "AC1EC0030EAB78308DB16A3EC78F****"
}, {
"Action" : "pub_mqtt",
"ActionCode" : "mqtt.trace.action.msg.pub.mqtt",
"ClientId" : "GID_test@@@producer",
"ActionInfo" : "Pub From Mqtt Client",
"Time" : "2021-05-21 15:08:19.234 ",
"MsgId" : "AC1EC0030EAB78308DB16A3EC78F****"
}, {
"Action" : "pub_mqtt",
"ActionCode" : "mqtt.trace.action.msg.pub.mqtt",
"ClientId" : "GID_test@@@producer",
"ActionInfo" : "Pub From Mqtt Client",
"Time" : "2021-05-21 15:08:19.234 ",
"MsgId" : "AC1EC0030EAB78308DB16A3EC78F****"
}, {
"Action" : "pub_mqtt",
"ActionCode" : "mqtt.trace.action.msg.pub.mqtt",
"ClientId" : "GID_test@@@producer",
"ActionInfo" : "Pub From Mqtt Client",
"Time" : "2021-05-21 15:08:19.234 ",
"MsgId" : "AC1EC0030EAB78308DB16A3EC78F****"
} ]
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
500 | SystemOverFlow | An error occurred while processing your request. Please try again. | 系统限流,请重试。 |
404 | ApiNotSupport | The specified API is not supported. | 当前接口不支持,请检查。 |
访问错误中心查看更多错误码。
控制台操作
除了调用QueryMqttTraceMessageOfClient接口,您还可以通过微消息队列MQTT版控制台查看设备的消息列表。具体操作,请参见消息轨迹查询。