All Products
Search
Document Center

ApsaraMQ for MQTT:SendMessage

Last Updated:Jun 10, 2026

Mengirim satu Paket dari aplikasi pada server cloud ke ApsaraMQ for MQTT.

Deskripsi operasi

  • The SendMessage operation is called by an application on a cloud server. This operation is complementary to the operation that is called to send a message from an ApsaraMQ for MQTT client. For information about the differences between the scenarios of sending messages from applications on cloud servers and the scenarios of sending messages from ApsaraMQ for MQTT clients, see Developer guide.

  • Messages that are sent by calling the SendMessage operation cannot be forwarded to ApsaraMQ for RocketMQ. If you want to use an ApsaraMQ for MQTT broker to forward messages to ApsaraMQ for RocketMQ, use an SDK to send the messages. The SendMessage operation supports up to 1,000 queries per second (QPS). For more information, see QPS limits.

  • Each successful call to the SendMessage operation is calculated as a message transaction per second (TPS). This affects the billing of your instance. For more information, see Billing rules.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

mq:SendMessage

none

*All Resource

*

None None

Parameter permintaan

Parameter

Type

Required

Description

Example

MqttTopic

string

Yes

Topik tempat Anda ingin mengirim Paket pada instans ApsaraMQ for MQTT.

TopicA

InstanceId

string

Yes

ID instans ApsaraMQ for MQTT. ID harus sama dengan ID instans yang digunakan oleh klien ApsaraMQ for MQTT. Anda dapat Tampilan ID instans di bagian Informasi Dasar pada halaman Detail Instans yang sesuai dengan instans di Konsol ApsaraMQ for MQTT.

post-cn-0pp12gl****

Payload

string

Yes

Konten Paket, yaitu muatan Paket. Enkode konten dalam Base64 untuk mencegah karakter non-cetak ditransmisikan.

test

Catatan

Untuk informasi tentang parameter lainnya, lihat Parameter umum dan Endpoint.

Elemen respons

Element

Type

Description

Example

object

MsgId

string

The unique message ID that is returned by the ApsaraMQ for MQTT broker after the message is sent.

0B736D997B7F45FF54E61C1C1B58****

RequestId

string

The unique ID that the system generates for the request. This parameter is a common parameter.

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

Contoh

Respons sukses

JSONformat

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

Kode kesalahan

HTTP status code

Error code

Error message

Description

400 CheckAccountInfoFailed An error occurred while checking the account information by the 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.
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.
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.
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.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.