tencent cloud

Feedback

SendBatchMessages

Last updated: 2023-08-09 14:43:29

1. API Description

Domain name for API request: tdmq.tencentcloudapi.com.

This API is used to batch send messages.

Note: the batch message sending API in TDMQ is to package messages into a batch on the service side of TDMQ-HTTP and then send the batch as a TCP request inside the service. Therefore, when using this API, you should still follow the logic of sending a single message: each message is an independent HTTP request, and multiple HTTP requests are aggregated into one batch inside the TDMQ-HTTP service and then sent to the server; that is, batch sending messages is the same as sending a single message in terms of usage, and batch aggregation is completed inside the TDMQ-HTTP service.

A maximum of 1000 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: SendBatchMessages.
Version Yes String Common Params. The value used for this API: 2020-02-17.
Region No String Common Params. This parameter is not required for this API.
Topic Yes String Name of the topic to which to send the message. It is better to be the full path of the topic, such as tenant/namespace/topic. If it is not specified, public/default will be used by default.
Payload Yes String Content of the message to be sent
StringToken No String String-Type token, which is optional and will be automatically obtained by the system.
ProducerName No String Producer name, which must be globally unique. If it is not configured, the system will automatically generate one.
SendTimeout No Integer Message sending timeout period in seconds. Default value: 30s
MaxPendingMessages No Integer Maximum number of produced messages which can be cached in the memory. Default value: 1000
BatchingMaxMessages No Integer Maximum number of messages in each batch. Default value: 1000 messages/batch
BatchingMaxPublishDelay No Integer Maximum wait time for each batch, after which the batch will be sent no matter whether the specified number or size of messages in the batch is reached. Default value: 10 ms
BatchingMaxBytes No Integer Maximum allowed size of messages in each batch. Default value: 128 KB

3. Output Parameters

Parameter Name Type Description
MessageId String Unique message ID
Note: this field may return null, indicating that no valid values can be obtained.
ErrorMsg String Error message. If an empty string is returned, no error occurred.
Note: this field may return null, indicating that no valid values can be obtained.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Sending multiple messages successfully

Input Example

https://tdmq.tencentcloudapi.com/?Action=SendBatchMessages
&Topic=tenant/namespace/topic
&Payload="hello TDMQ"
&<Common request parameters>

Output Example

{
    "Response": {
        "RequestId": "36713f94-d07d-4b96-babf-42d139276f23",
        "MessageId": "71:12:0:0",
        "ErrorMsg": ""
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.CreateProducerError An error occurred while creating the producer.
FailedOperation.CreatePulsarClientError An error occurred while creating the TDMQ client.
FailedOperation.MaxMessageSizeError The message size exceeds the upper limit of 1 MB.
FailedOperation.MessageIDError The uploaded msgID is incorrect.
FailedOperation.ReceiveError An error occurred while receiving the message.
FailedOperation.ReceiveTimeout Message receiving timed out. Please try again.
FailedOperation.SendMessageTimeoutError Message sending timed out.
FailedOperation.TopicTypeError Please use a partition topic.
InvalidParameter.TenantNotFound The uploaded tenant name is incorrect.
InvalidParameter.TokenNotFound The correct token was not obtained.
InvalidParameterValue.TopicNotFound The uploaded topic name is incorrect.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support