SendMessageBatch

Method for simultaneously delivering up to 10 messages to the specified queue. When sending messages to a FIFO queue, they will be delivered in the order that they are sent.

The result of the send action on each message is reported individually in the response. Check all the results, because the send message batch action might fail even if code 200 is returned in response to the SendMessageBatch method call. A message can include XML, JSON, and unformatted text. The following Unicode characters are supported:

  • #x9
  • #xA
  • #xD
  • from #x20 to #xD7FF
  • from #xE000 to #xFFFD
  • from #x10000 to #x10FFFFF

The maximum batch size is 256 KB.

If the DelaySeconds parameter is not specified for a batch entry, the value for the default queue will be used.

Request

Request parameters

Parameter Type Required parameter Description
SendMessageBatchRequestEntry.N array Yes The SendMessageBatchRequestEntry array.
QueueUrl string Yes URL of the queue that messages are sent to.

Response

Successful response fields

Field Type Description
BatchResultErrorEntry.N array The BatchResultErrorEntry array with information about the messages that failed to be enqueued.
SendMessageBatchResultEntry.N array The SendMessageBatchResultEntry array with information about the messages that have been successfully enqueued.

SendMessageBatch errors

For a list of errors common for all methods, see Common errors.

HTTP code Error ID Description
400 BatchEntryIdsNotDistinct Two or more batch entries in the request have the same ID.
400 BatchRequestTooLong The length of all the messages put together is more than the limit.
400 EmptyBatchRequest The batch request doesn't contain any entries.
400 InvalidBatchEntryId The ID of a batch entry is invalid.
400 TooManyEntriesInBatchRequest Too many entries in a batch.
400 UnsupportedOperation The operation is not supported.

Sample request

Action=SendMessageBatch
&Version=2012-11-05
&QueueUrl=https://message-queue.api.cloud.yandex.net/b1g8ad42m6he1ooql78r/dj600000000000le07ol/sample-queue
&SendMessageBatchRequestEntry.1.Id=123qwe
&SendMessageBatchRequestEntry.1.MessageBody=HelloWorld
&SendMessageBatchRequestEntry.2.Id=321ewq
&SendMessageBatchRequestEntry.2.MessageBody=WorldHello

For more information about forming requests, see General API request format.

Response example

<SendMessageBatchResponse>
    <SendMessageBatchResult>
        <SendMessageBatchResultEntry>
            <Id>321ewq</Id>
            <MD5OfMessageBody>aa1e70b237224fdeff0d04e86dec57ac</MD5OfMessageBody>
            <MessageId>13b0e327-8aa4cd4e-92feed42-15ccbec</MessageId>
        </SendMessageBatchResultEntry>
        <SendMessageBatchResultEntry>
            <Id>123qwe</Id>
            <MD5OfMessageBody>68e109f0f40ca72a15e05cc22786f8e6</MD5OfMessageBody>
            <MessageId>10e93fc8-266eb1c1-15e67924-15cf4d4</MessageId>
        </SendMessageBatchResultEntry>
    </SendMessageBatchResult>
    <ResponseMetadata>
        <RequestId>7b4175bf-4a7a7572-94e7a240-15ccbeb-c3d59faf841a51e0fd1184b1505d606a</RequestId>
    </ResponseMetadata>
</SendMessageBatchResponse>