文档

SendMessage - 向云消息队列 MQTT 版发送单条消息

更新时间:
一键部署

从服务端应用向云消息队列 MQTT 版发送单条消息。

接口说明

  • SendMessage 接口为服务端应用调用,与 MQTT 客户端发送消息互补。服务端和客户端的使用场景区别,请参见开发指南使用指引
  • 调用 SendMessage 接口前,请确认您的云消息队列 MQTT 版实例的内核版本为 V3.3.0 或以上版本。内核版本信息可在控制台实例详情页面获取。
  • 调用 SendMessage 接口发送的消息不支持流转至云消息队列 RocketMQ 版。若需要通过 MQTT 服务端将消息流转至云消息队列 RocketMQ 版,请使用 SDK 发送消息SendMessage 接口的 QPS 限制为 1000。更多信息,请参见 QPS 限制
  • 每成功调用一次 SendMessage 接口,都会计算为一次消息 TPS,从而影响您的计费。计费详情,请参见计费说明

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

当前API暂无授权信息透出。

请求参数

名称类型必填描述示例值
MqttTopicstring

云消息队列 MQTT 版的 Topic,即消息发送的目标 Topic。

TopicA
InstanceIdstring

云消息队列 MQTT 版实例的 ID,一定要和客户端实际使用的实例 ID 匹配。您可以在控制台实例详情页面的基础信息区域查看。

post-cn-0pp12gl****
Payloadstring

消息内容,即消息负载。建议自行做 Base64 编码,避免传输不可见字符。

test
说明 更多参数说明请参见公共参数服务接入点

返回参数

名称类型描述示例值
object
MsgIdstring

消息的唯一标识,消息发送成功后服务端会返回消息 ID。

0B736D997B7F45FF54E61C1C1B58****
RequestIdstring

公共参数,每个请求的 ID 都是唯一的。

020F6A43-19E6-4B6E-B846-44EB31DF****

示例

正常返回示例

JSON格式

{
  "MsgId": "0B736D997B7F45FF54E61C1C1B58****",
  "RequestId": "020F6A43-19E6-4B6E-B846-44EB31DF****"
}

错误码

HTTP status code错误码错误信息描述
400CheckAccountInfoFailedAn error occurred while checking the account information by the STS token.解析STS Token账号信息失败。
400InstancePermissionCheckFailedAn error occurred while validating the permissions of the instance. Please verify the account that created the instance and its permissions settings.实例权限校验失败,请确认MQTT实例的所属关系以及授权策略。
400ParameterCheckFailedAn error occurred while validating the parameters. The parameters may be missing or invalid.参数校验失败,可能缺失或者传入值非法。
400PermissionCheckFailedAn error occurred while validating the resource permissions. Please check the account that created the instance, topic, and GroupId, and check their permission settings.资源权限校验失败,请检查实例、Topic和Group ID的所属权限和授权策略。
400InvalidParameter.%sAn error occurred while validating the parameter. The parameter may be missing or invalid.参数校验失败,可能缺失或者传入值非法。
404ApiNotSupportThe specified API is not supported.当前接口不支持,请检查。
500InternalErrorAn error occurred while processing your request. Try again later.MQTT后端服务异常,请重试。
500SendMessageFailedA storage exception occurred while sending the message. Please try again.由于后端存储异常,消息发送失败,请重试。
500SystemOverFlowAn error occurred while processing your request. Please try again.系统限流,请重试。

访问错误中心查看更多错误码。

变更历史

变更时间变更内容概要操作
暂无变更历史
  • 本页导读 (1)
文档反馈