Share this page

# LrSqsClient.deleteMessage

Deletes a message from the queue.

`public static void deleteMessage(String receiptHandle)`

`public static void deleteMessage(LrSqsMessage message)`

## Arguments

Name | Description
--- | ---
receiptHandle | The handle contained within the LrSqsMessage.
message | The LrSqsMessage to delete.

## Return values

The function does not return any values.

## General information

This function deletes a message from the queue. The message can be identified by the receipt handle, or by the full message. The message is also deleted from the queue by default after a period of time that is set when the queue is configured.

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