Message sending

Last updated: 2020-02-26 15:41:01

PDF

Interface description

This API (SendMessage) is used to send a message to the specified queue.

  • Domain name requested by public network API: https://cmq-queue-{$region}.api.qcloud.com
  • Domain name requested by private network API: http://cmq-queue-{$region}.api.tencentyun.com

The above {$region} in the domain name needs to be replaced with a specific region : gz (Guangzhou), sh (Shanghai), bj (Beijing), shjr (Shanghai Finance), szjr (Shenzhen Finance), hk (Hong Kong, China), cd (Chengdu), ca (North America), usw (American West), sg (Singapore). The region value in the common parameters should be consistent with the region value of the domain name. If there is any inconsistency, the request will be sent to the region specified by the domain name region based on the region value of the domain name.

At any time (including during internal testing), if the public network downstream Traffic is generated by using a public network domain name, Traffic and cost will be charged. Therefore, users of the service on Tencent Cloud are strongly recommended to use it. Private network Domain name, private network will not produce Traffic cost.

Input Parameter

The following request parameter list only lists the API request parameters. For other parameters, please see Common Request Parameters page.

Parameter name Required Type Description
QueueName Yes String Queue name, which is unique under the same account in a single region. The queue name is a string of no more than 64 characters, must begin with a letter, and the rest can contain letters, numbers, and dashes (-).
MsgBody Yes String Message body. At least 1Byte, the maximum length is limited by the set queue message maximum length attribute.
DelaySeconds No Int In seconds, indicates how long it takes to delay the message before the user can see the message after it is sent to the queue.

Output Parameter

Parameter name Type Description
Code Int 0: indicates success. Others: error. For more information, please see Common error code .
Message String Error message.
RequestId String When an internal server error occurs in the request ID, generated by the server, the user can submit this ID to Backend Background to locate the problem.
MsgId String The server generates a unique identity ID for the message.

Error Codes

Please check Common error code .

Example

Enter:

Https://domain/v2/index.php?Action=SendMessage & queueName=test-queue-123 & msgBody=helloworld & <Common Request Parameters>

Output:

{
"code" : 0,
"message" : "",
"requestId":"14534664555",
"msgId":"123345346"
}