全部產品
Search
文件中心

ApsaraMQ for MQTT:SendMessage - 向雲Message QueueTT 版發送單條訊息

更新時間:Dec 21, 2025

從服務端應用向雲Message QueueTT 版發送單條訊息。

介面說明

  • SendMessage 介面為服務端應用調用,與 MQTT 用戶端發送訊息互補。服務端和用戶端的使用情境區別,請參見開發指南使用指引

  • 調用 SendMessage 介面發送的訊息不支援流轉至雲訊息佇列 RocketMQ 版。若需要通過 MQTT 服務端將訊息流程轉至雲訊息佇列 RocketMQ 版,請使用 SDK 發送訊息SendMessage 介面的 QPS 限制為 1000。更多資訊,請參見 QPS 限制

  • 每成功調用一次 SendMessage 介面,都會計算為一次訊息 TPS,從而影響您的計費。計費詳情,請參見計費說明

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

mq:SendMessage

none

*全部資源

*

請求參數

名稱

類型

必填

描述

樣本值

MqttTopic

string

雲Message QueueTT 版的 Topic,即訊息發送的目標 Topic。

TopicA

InstanceId

string

雲Message QueueTT 版執行個體的 ID,一定要和用戶端實際使用的執行個體 ID 匹配。您可以在控制台執行個體詳情頁面的基礎資訊地區查看。

post-cn-0pp12gl****

Payload

string

訊息內容,即訊息負載。建議自行做 Base 64 編碼,避免傳輸不可見字元。

test

說明

更多參數說明請參見公用參數服務存取點

返回參數

名稱

類型

描述

樣本值

object

MsgId

string

訊息的唯一標識,訊息發送成功後服務端會返回訊息 ID。

0B736D997B7F45FF54E61C1C1B58****

RequestId

string

公用參數,每個請求的 ID 都是唯一的。

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

樣本

正常返回樣本

JSON格式

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

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 CheckAccountInfoFailed An error occurred while checking the account information by the STS token. 解析STS Token帳號資訊失敗。
400 InstancePermissionCheckFailed An error occurred while validating the permissions of the instance. Please verify the account that created the instance and its permissions settings. 執行個體許可權校正失敗,請確認MQTT執行個體的所屬關係以及授權策略。
400 ParameterCheckFailed An error occurred while validating the parameters. The parameters may be missing or invalid. 參數校正失敗,可能缺失或者傳入值非法。
400 PermissionCheckFailed An 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的所屬許可權和授權策略。
400 InvalidParameter.%s An error occurred while validating the parameter. The parameter may be missing or invalid. 參數校正失敗,可能缺失或者傳入值非法。
500 InternalError An error occurred while processing your request. Try again later. MQTT後端服務異常,請重試。
500 SendMessageFailed A storage exception occurred while sending the message. Please try again. 由於後端儲存異常,訊息發送失敗,請重試。
500 SystemOverFlow An error occurred while processing your request. Please try again. 系統限流,請重試。
404 ApiNotSupport The specified API is not supported. 當前介面不支援,請檢查。

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情