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...

SendMessage

Description

The SendMessage action delivers a message to the specified queue. The maximum allowed message size is 64 KB.

Important

The following list shows the characters (in Unicode) allowed in your message, according to the W3C XML specification. For more information, go to http://www.w3.org/TR/REC-xml/#charsets. If you send any characters not included in the list, your request will be rejected.

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

Request Parameters

The following table lists the special request parameters the SendMessage action uses in addition to the common request parameters all actions use. For more information, see Common Query Parameters.

NameDescriptionRequired

MessageBody

The message to send.

Type: String maximum 64 KB in size. For a list of allowed characters, see the preceding important note.

Yes

DelaySeconds

The number of seconds to delay a specific message. Messages with a positive DelaySeconds value become available for processing after the delay time is finished. If you don't specify a value, the default value for the queue applies.

Type: Integer from 0 to 900 (15 minutes). If this parameter is not used, the default value for the queue applies.

No

Response Elements

The following table lists the response elements the SendMessage action returns in addition to the common response elements all actions return (for more information, see Responses section in the Amazon SQS Developer Guide.

NameDescription

MD5OfMessageBody

An MD5 digest of the non-URL-encoded message body string. You can use this to verify that SQS received the message correctly. SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://faqs.org/rfcs/rfc1321.html.

Type: String

Ancestor: SendMessageResult

MessageId

An element containing the message ID of the message sent to the queue. For more information, see Queue and Message Identifiers in the Amazon SQS Developer Guide.

Type: String

Ancestor: SendMessageResult

Special Errors

The following table lists the special errors the SendMessage action returns in addition to the common errors all actions return. For more information, see Common Errors.

ErrorDescriptionHTTP Status Code

InvalidMessageContents

The message contains characters outside the allowed set.

400

MessageTooLong

The message size cannot exceed 64 KB.

400

Examples

Sample Request

The following example SendMessage request sends a message containing "Your Message Text" 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.

http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=SendMessage
&MessageBody=This+is+a+test+message
&Version=2009-02-01
&SignatureMethod=HmacSHA256
&Expires=2009-04-18T22%3A52%3A43PST
&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

The following example response includes the MD5 digest for Your Message Text.

<SendMessageResponse>
    <SendMessageResult>
        <MD5OfMessageBody>
            fafb00f5732ab283681e124bf8747ed1
        </MD5OfMessageBody>
        <MessageId>
            5fea7756-0ea4-451a-a703-a558b933e274
        </MessageId>
    </SendMessageResult>
    <ResponseMetadata>
        <RequestId>
            27daac76-34dd-47df-bd01-1f6e873584a0
        </RequestId>
    </ResponseMetadata>
</SendMessageResponse>