Jump to Content

New API Documentation - Developer Preview Available

We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.

Class SendMessageCommandProtected

Delivers a message to the specified queue.

A message can include only XML, JSON, and unformatted text. The following Unicode characters are allowed:

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

Any characters not included in this list will be rejected. For more information, see the W3C specification for characters.

Example

Use a bare-bones client and the command you need to make an API call.

import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; // ES Modules import
// const { SQSClient, SendMessageCommand } = require("@aws-sdk/client-sqs"); // CommonJS import
const client = new SQSClient(config);
const input = { // SendMessageRequest
QueueUrl: "STRING_VALUE", // required
MessageBody: "STRING_VALUE", // required
DelaySeconds: Number("int"),
MessageAttributes: { // MessageBodyAttributeMap
"<keys>": { // MessageAttributeValue
StringValue: "STRING_VALUE",
BinaryValue: "BLOB_VALUE",
StringListValues: [ // StringList
"STRING_VALUE",
],
BinaryListValues: [ // BinaryList
"BLOB_VALUE",
],
DataType: "STRING_VALUE", // required
},
},
MessageSystemAttributes: { // MessageBodySystemAttributeMap
"<keys>": { // MessageSystemAttributeValue
StringValue: "STRING_VALUE",
BinaryValue: "BLOB_VALUE",
StringListValues: [
"STRING_VALUE",
],
BinaryListValues: [
"BLOB_VALUE",
],
DataType: "STRING_VALUE", // required
},
},
MessageDeduplicationId: "STRING_VALUE",
MessageGroupId: "STRING_VALUE",
};
const command = new SendMessageCommand(input);
const response = await client.send(command);
// { // SendMessageResult
// MD5OfMessageBody: "STRING_VALUE",
// MD5OfMessageAttributes: "STRING_VALUE",
// MD5OfMessageSystemAttributes: "STRING_VALUE",
// MessageId: "STRING_VALUE",
// SequenceNumber: "STRING_VALUE",
// };

Param

SendMessageCommandInput

Returns

SendMessageCommandOutput

See

Throws

InvalidMessageContents (client fault)

The message contains characters outside the allowed set.

Throws

UnsupportedOperation (client fault)

Error code 400. Unsupported operation.

Throws

SQSServiceException

Base exception class for all service exceptions from SQS service.

Hierarchy

Constructors

Properties

middlewareStack: MiddlewareStack<SendMessageCommandInput, SendMessageCommandOutput>

Methods