tencent cloud

피드백

Send messages in batch

마지막 업데이트 시간:2021-04-06 19:17:38

    Note:

    This is a legacy API which has been hidden and will no longer be updated. We recommend using the new CMQ API 3.0 which is standardized and faster.

    Interface description

    This API (BatchSendMessage) is used to send batches (up to 16 messages) to a 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 Financial), szjr (Shenzhen Financial), hk (China Hong Kong), cd (Chengdu), ca (North American), usw (Maxi), 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.

    Note:

    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.n Yes String Message body. Represents a message in this batch. Currently, the number of messages in batch cannot exceed 16.

    For the convenience of users, n can start with 0 or 1, but it must be continuous, such as sending two messages, which can be (msgBody.0, msgBody.1) or (msgBody.1, msgBody.2).

    Note: since the total size of all messages (excluding headers and other parameters, only msgBody) is limited to 64k, it is recommended to plan the number of batches to be sent in advance.
    DelaySeconds No Int It is measured in seconds, indicating how long it takes to delay the message before the user can see it after it is sent to the queue. (this delay is valid for a batch of messages and does not support many-to-many mapping)

    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.
    MsgList Array The server generates a unique identification ID list of messages, and each element is the information of a message.

    MsgList is defined as follows:

    Parameter name Type Description
    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=BatchSendMessage & queueName=test-queue-123 & msgBody.1=helloworld1 & msgBody.2=helloworld2 & <Common Request Parameters>

    Output:

    {
    "code" : 0,
    "message" : "",
    "requestId":"14534664555",
    "msgList":
      [
        {
          "msgId":"123345346"
        },
        {
           "msgId":"456436346"
        }
      ]
    }