Queue / Action / delete_messages

delete_messages#

SQS.Queue.delete_messages(**kwargs)#

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.

Warning

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.

Some 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:

&AttributeName.1=first

&AttributeName.2=second

See also: AWS API Documentation

Request Syntax

response = queue.delete_messages(
    Entries=[
        {
            'Id': 'string',
            'ReceiptHandle': 'string'
        },
    ]
)
Parameters:

Entries (list) –

[REQUIRED]

A list of receipt handles for the messages to be deleted.

  • (dict) –

    Encloses a receipt handle and an identifier for it.

    • Id (string) – [REQUIRED]

      An identifier for this particular receipt handle. This is used to communicate the result.

      Note

      The ``Id``s of a batch request need to be unique within a request.

      This identifier can have up to 80 characters. The following characters are accepted: alphanumeric characters, hyphens(-), and underscores (_).

    • ReceiptHandle (string) – [REQUIRED]

      A receipt handle.

Return type:

dict

Returns:

Response Syntax

{
    'Successful': [
        {
            'Id': 'string'
        },
    ],
    'Failed': [
        {
            'Id': 'string',
            'SenderFault': True|False,
            'Code': 'string',
            'Message': 'string'
        },
    ]
}

Response Structure

  • (dict) –

    For each message in the batch, the response contains a DeleteMessageBatchResultEntry tag if the message is deleted or a BatchResultErrorEntry tag if the message can’t be deleted.

    • Successful (list) –

      A list of DeleteMessageBatchResultEntry items.

      • (dict) –

        Encloses the Id of an entry in DeleteMessageBatch.

        • Id (string) –

          Represents a successfully deleted message.

    • Failed (list) –

      A list of BatchResultErrorEntry items.

      • (dict) –

        Gives a detailed description of the result of an action on each entry in the request.

        • Id (string) –

          The Id of an entry in a batch request.

        • SenderFault (boolean) –

          Specifies whether the error happened due to the caller of the batch API action.

        • Code (string) –

          An error code representing why the action failed on this entry.

        • Message (string) –

          A message explaining why the action failed on this entry.