Skip to content

delete_message_batch

delete_message_batch(
    queue_url: String,
    entries: DeleteMessageBatchRequestEntryList,
    *,
    config_overrides: Optional[SQSClientConfig] = None,
) -> DeleteMessageBatchResult

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.

Parameters:

  • queue_url (String) –

    The URL of the Amazon SQS queue from which messages are deleted.

    Queue URLs and names are case-sensitive.

  • entries (DeleteMessageBatchRequestEntryList) –

    Lists the receipt handles for the messages to be deleted.

Raises:

Source code in docs_src/capo_sqs/_services/sqs.py
def delete_message_batch(
    self,
    queue_url: "capo_sqs.types.string.String",
    entries: "capo_sqs.types.delete_message_batch_request_entry_list.DeleteMessageBatchRequestEntryList",
    *,
    config_overrides: Optional[SQSClientConfig] = None,
) -> "capo_sqs.types.delete_message_batch_result.DeleteMessageBatchResult":
    """<p>Deletes up to ten messages from the specified queue. This is a batch version of <code> <a>DeleteMessage</a>.</code> The result of the action on each message is reported individually in the response.</p> <important> <p>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 <code>200</code>.</p> </important>

    Args:
        queue_url: <p>The URL of the Amazon SQS queue from which messages are deleted.</p> <p>Queue URLs and names are case-sensitive.</p>
        entries: <p>Lists the receipt handles for the messages to be deleted.</p>

    Raises:
        capo_sqs.errors.batch_entry_ids_not_distinct.BatchEntryIdsNotDistinct: <p>Two or more batch entries in the request have the same <code>Id</code>.</p>
        capo_sqs.errors.empty_batch_request.EmptyBatchRequest: <p>The batch request doesn't contain any entries.</p>
        capo_sqs.errors.invalid_address.InvalidAddress: <p>The specified ID is invalid.</p>
        capo_sqs.errors.invalid_batch_entry_id.InvalidBatchEntryId: <p>The <code>Id</code> of a batch entry in a batch request doesn't abide by the specification.</p>
        capo_sqs.errors.invalid_security.InvalidSecurity: <p>The request was not made over HTTPS or did not use SigV4 for signing.</p>
        capo_sqs.errors.queue_does_not_exist.QueueDoesNotExist: <p>Ensure that the <code>QueueUrl</code> is correct and that the queue has not been deleted.</p>
        capo_sqs.errors.request_throttled.RequestThrottled: <p>The request was denied due to request throttling.</p> <ul> <li> <p>Exceeds the permitted request rate for the queue or for the recipient of the request.</p> </li> <li> <p>Ensure that the request rate is within the Amazon SQS limits for sending messages. For more information, see <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-quotas.html#quotas-requests">Amazon SQS quotas</a> in the <i>Amazon SQS Developer Guide</i>.</p> </li> </ul>
        capo_sqs.errors.too_many_entries_in_batch_request.TooManyEntriesInBatchRequest: <p>The batch request contains more entries than permissible. For Amazon SQS, the maximum number of entries you can include in a single <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessageBatch.html">SendMessageBatch</a>, <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_DeleteMessageBatch.html">DeleteMessageBatch</a>, or <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ChangeMessageVisibilityBatch.html">ChangeMessageVisibilityBatch</a> request is 10.</p>
        capo_sqs.errors.unsupported_operation.UnsupportedOperation: <p>Error code 400. Unsupported operation.</p>
        capo_sqs.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sqs.types.delete_message_batch_request.DeleteMessageBatchRequest]",
    ) -> OperationResponse[
        "capo_sqs.types.delete_message_batch_result.DeleteMessageBatchResult"
    ]:
        import capo_sqs._operations.amazon_sqs.delete_message_batch

        output, http_response = (
            capo_sqs._operations.amazon_sqs.delete_message_batch.delete_message_batch(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteMessageBatch")
    )
    input_: capo_sqs.types.delete_message_batch_request.DeleteMessageBatchRequest = {
        "queue_url": queue_url,
        "entries": entries,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output