All Products
Search
Document Center

ApsaraMQ for MQTT:QueryMqttTraceMessagePublish

Last Updated:Jul 31, 2025

Queries the trace of a message. If a message is not sent or received as expected, you can call this operation to view the message details to troubleshoot the issue. For example, you can query the time when the message is published and the client that publishes the message.

Operation description

  • Each successful call to the QueryMqttTraceMessagePublish operation increases the messaging transactions per second (TPS). This affects the billing of your instance. For more information, see Billing rules.
  • You can call this operation up to 500 times per second per account. If the limit is exceeded, throttling is triggered. This may affect your business. We recommend that you take note of this limit when you call this operation. For more information, see Limits on QPS.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
mq:QueryMqttPubTracenone
*Instance
acs:mq:{#regionId}:{#accountId}:{#InstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
MqttRegionIdstringYes

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

cn-hangzhou
InstanceIdstringYes

The ID of the ApsaraMQ for MQTT instance. The ID must be consistent with the ID of the instance that the ApsaraMQ for MQTT client uses. You can view the instance ID in the Basic Information section on the Instance Details page that corresponds to the instance in the ApsaraMQ for MQTT console.

mqtt-cn-i7m26mf****
MsgIdstringYes

The message ID.

AC1EC0030EAB78308DB16A3EC773****
BeginTimelongYes

The beginning of the time range to query. The value of this parameter is a UNIX timestamp in milliseconds.

1618646400000
EndTimelongYes

The end of the time range to query. The value of this parameter is a UNIX timestamp in milliseconds.

1621591200000

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The request ID. You can use the ID to troubleshoot issues. This parameter is a common parameter.

69AD5550-BF22-438A-9202-A6E89185****
MessageTraceListsarray<object>

The message traces.

MessageTraceListsobject
Timestring

The time when the message was sent.

2021-05-21 15:08:19.210
Actionstring

The action on the message. Valid values:

  • pub_mqtt: indicates that the message was sent by an ApsaraMQ for MQTT client.
  • pub_mq: indicates that the message was sent by an ApsaraMQ for RocketMQ client.
pub_mqtt
ActionCodestring

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

  • mqtt.trace.action.msg.pub.mqtt: This value is returned if the value of Action is pub_mqtt.
  • mqtt.trace.action.msg.pub.mq: This value is returned if the value of Action is pub_mq.
mqtt.trace.action.msg.pub.mqtt
ActionInfostring

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

  • Pub From Mqtt Client: This value is returned if the value of Action is pub_mqtt.
  • Pub From MQ: This value is returned if the value of Action is pub_mq.
Pub From Mqtt Client
MsgIdstring

The message ID.

AC1EC0030EAB78308DB16A3EC773BD95
ClientIdstring

The ID of the client that sends the message.

GID_test@@@producer

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError message
404ApiNotSupportThe specified API is not supported.
500SystemOverFlowAn error occurred while processing your request. Please try again.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2025-02-10The Error code has changedView Change Details