Amazon Simple Queue Service
API Reference (API Version 2012-11-05)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

SendMessageBatch

Description

Delivers up to ten messages to the specified queue. This is a batch version of SendMessage. The result of the send action on each message is reported individually in the response. The maximum allowed individual message size is 256 KB (262,144 bytes).

The maximum total payload size (i.e., the sum of all a batch's individual message lengths) is also 256 KB (262,144 bytes).

If the DelaySeconds parameter is not specified for an entry, the default for the queue is used.

Important

The following list shows the characters (in Unicode) that are allowed in your message, according to the W3C XML specification. For more information, go to http://www.faqs.org/rfcs/rfc1321.html. If you send any characters that are not included in the list, your request will be rejected.

#x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]

Important

Because the batch request can result in a combination of successful and unsuccessful actions, you should check for batch errors even when the call returns an HTTP status code of 200.

Note

Some API actions take lists of parameters. These lists are specified using the param.n notation. Values of n are integers starting from 1. For example, a parameter list with two elements looks like this:

&Attribute.1=this

&Attribute.2=that

Request Parameters

For information about the common parameters that all actions use, see Common Parameters.

SendMessageBatchRequestEntry.member.N

A list of SendMessageBatchRequestEntry items.

Type: SendMessageBatchRequestEntry list

Required: Yes

QueueUrl

The URL of the Amazon SQS queue to take action on.

Type: String

Required: Yes

Response Elements

The following elements are returned in a structure named SendMessageBatchResult.

Failed

A list of BatchResultErrorEntry items with the error detail about each message that could not be enqueued.

Type: BatchResultErrorEntry list

Successful

A list of SendMessageBatchResultEntry items.

Type: SendMessageBatchResultEntry list

Errors

For information about the errors that are common to all actions, see Common Errors.

BatchEntryIdsNotDistinct

Two or more batch entries have the same Id in the request.

HTTP Status Code: 400

BatchRequestTooLong

The length of all the messages put together is more than the limit.

HTTP Status Code: 400

EmptyBatchRequest

Batch request does not contain an entry.

HTTP Status Code: 400

InvalidBatchEntryId

The Id of a batch entry in a batch request does not abide by the specification.

HTTP Status Code: 400

TooManyEntriesInBatchRequest

Batch request contains more number of entries than permissible.

HTTP Status Code: 400

UnsupportedOperation

Error code 400. Unsupported operation.

HTTP Status Code: 400

Examples

The following example SendMessageBatch request sends two messages to the queue. You must URL encode the entire URL; however, we've URL encoded only the message body to make the example easier for you to read. The following example response includes the MD5 digest for the messages.

Sample Request

        
http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=SendMessageBatch
&SendMessageBatchRequestEntry.1.Id=test_msg_001
&SendMessageBatchRequestEntry.1.MessageBody=test%20message%20body%201
&SendMessageBatchRequestEntry.2.Id=test_msg_002
&SendMessageBatchRequestEntry.2.MessageBody=test%20message%20body%202
&SendMessageBatchRequestEntry.2.DelaySeconds=60
&SendMessageBatchRequestEntry.2.MessageAttribute.1.Name=test_attribute_name_1
&SendMessageBatchRequestEntry.2.MessageAttribute.1.Value.StringValue=test_attribute_value_1
&SendMessageBatchRequestEntry.2.MessageAttribute.1.Value.DataType=String
&Version=2012-11-05
&SignatureMethod=HmacSHA256
&Expires=2014-05-05T22%3A52%3A43PST
&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

      

Sample Response

        
<SendMessageBatchResponse>
<SendMessageBatchResult>
    <SendMessageBatchResultEntry>
        <Id>test_msg_001</Id>
        <MessageId>0a5231c7-8bff-4955-be2e-8dc7c50a25fa</MessageId>
        <MD5OfMessageBody>0e024d309850c78cba5eabbeff7cae71</MD5OfMessageBody>
    </SendMessageBatchResultEntry>
    <SendMessageBatchResultEntry>
        <Id>test_msg_002</Id>
        <MessageId>15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9</MessageId>
        <MD5OfMessageBody>7fb8146a82f95e0af155278f406862c2</MD5OfMessageBody>
        <MD5OfMessageAttributes>295c5fa15a51aae6884d1d7c1d99ca50</MD5OfMessageAttributes>
    </SendMessageBatchResultEntry>
</SendMessageBatchResult>
<ResponseMetadata>
    <RequestId>ca1ad5d0-8271-408b-8d0f-1351bf547e74</RequestId>
</ResponseMetadata>
</SendMessageBatchResponse>