Share this page

# LrSqsClient.deleteMessageBatch

Deletes a message batch from the queue.

`public static LrSqsDeleteMessageBatchRequestStatus deleteMessageBatch(Collection<?> batch)`

## Arguments

Name | Description
--- | ---
batch | A collection of LrSqsMessage or Strings (handle receipts)

## Return values

The function returns an LrSqsDeleteMessageBatchRequestStatus object. For details, see LrSqsDeleteMessageBatchRequestStatus.

## General information

This function deletes a message batch. It works in the same way as LrSqsClient.deleteMessage, but applies to a message batch instead of an individual message.

The batch can hold any number of messages. Upon calling the deleteMessageBatch() function, the batch is split into smaller collections, of at most 10 messages each, and each such collection is deleted in a separate request.

## Example

Copy code

    public void receiveMessageTest(){

            LrSqsClient.initClient(region, standardQueueUrl);

            LrSqsMessage message = LrSqsClient.receiveMessage();
            lr.output_message("Got 1 message: " + message.body());
            LrSqsClient.deleteMessage(message.receiptHandle());

            List<LrSqsMessage> collection = LrSqsClient.receiveMessages(5, 20);
            for (LrSqsMessage m : collection) {
                lr.output_message("Got message in collection: " + m.body());
                LrSqsClient.deleteMessage(m);
            }

            List<LrSqsMessage> collectionEx =   LrSqsClient.receiveMessagesEx(3, 20, null, null, new ArrayList() {{ add("MessageGroupId"); }}, null);
            for (LrSqsMessage m : collectionEx) {
                String messageGroupId = m.systemAttributesAsStrings().get("MessageGroupId");
                lr.log_message("Got message in collectionEX: " + messageGroupId + " " + m.body());
            }

            LrSqsDeleteMessageBatchRequestStatus status = LrSqsClient.deleteMessageBatch(collectionEx);

            LrSqsClient.closeClient();
    }

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: