- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
DeleteMessageBatchCommand
Deletes up to ten messages from the specified queue. This is a batch version of DeleteMessage.
The result of the action on each message is reported individually in the response.
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
.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { SQSClient, DeleteMessageBatchCommand } from "@aws-sdk/client-sqs"; // ES Modules import
// const { SQSClient, DeleteMessageBatchCommand } = require("@aws-sdk/client-sqs"); // CommonJS import
const client = new SQSClient(config);
const input = { // DeleteMessageBatchRequest
QueueUrl: "STRING_VALUE", // required
Entries: [ // DeleteMessageBatchRequestEntryList // required
{ // DeleteMessageBatchRequestEntry
Id: "STRING_VALUE", // required
ReceiptHandle: "STRING_VALUE", // required
},
],
};
const command = new DeleteMessageBatchCommand(input);
const response = await client.send(command);
// { // DeleteMessageBatchResult
// Successful: [ // DeleteMessageBatchResultEntryList // required
// { // DeleteMessageBatchResultEntry
// Id: "STRING_VALUE", // required
// },
// ],
// Failed: [ // BatchResultErrorEntryList // required
// { // BatchResultErrorEntry
// Id: "STRING_VALUE", // required
// SenderFault: true || false, // required
// Code: "STRING_VALUE", // required
// Message: "STRING_VALUE",
// },
// ],
// };
DeleteMessageBatchCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
Entries Required | DeleteMessageBatchRequestEntry[] | undefined | Lists the receipt handles for the messages to be deleted. |
QueueUrl Required | string | undefined | The URL of the Amazon SQS queue from which messages are deleted. Queue URLs and names are case-sensitive. |
DeleteMessageBatchCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Failed Required | BatchResultErrorEntry[] | undefined | A list of |
Successful Required | DeleteMessageBatchResultEntry[] | undefined | A list of |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
BatchEntryIdsNotDistinct | client | Two or more batch entries in the request have the same |
EmptyBatchRequest | client | The batch request doesn't contain any entries. |
InvalidAddress | client | The specified ID is invalid. |
InvalidBatchEntryId | client | The |
InvalidSecurity | client | The request was not made over HTTPS or did not use SigV4 for signing. |
QueueDoesNotExist | client | Ensure that the |
RequestThrottled | client | The request was denied due to request throttling.
|
TooManyEntriesInBatchRequest | client | The batch request contains more entries than permissible. For Amazon SQS, the maximum number of entries you can include in a single SendMessageBatch , DeleteMessageBatch , or ChangeMessageVisibilityBatch request is 10. |
UnsupportedOperation | client | Error code 400. Unsupported operation. |
SQSServiceException | Base exception class for all service exceptions from SQS service. |