Changes a message's visibility timeout.

public static void changeMessageVisibility(String receiptHandle, int visibilityTimeout)


receiptHandle The handle contained within the LrSqsMessage.
visibilityTimeout The new VisibilityTimeout value.

Return values

This function does not return any values.

General information

Message visibility is an AWS mechanism that prevents a client from receiving the same message multiple times. When the client receives a message, it is not automatically deleted from the queue. Therefore, a client could call one of the receiveMessage APIs and receive the same message again. To prevent this, SQS makes the message “invisible” to clients for a period of time after being received by a client.


Copy code
public void changeVisibility() {

        LrSqsClient.initClient(region, standardQueueUrl)
        LrSqsMessage message1 = LrSqsClient.receiveMessage();
        if (message1 != null){
            LrSqsClient.changeMessageVisibility(message1.receiptHandle(), 20);
        List <LrSqsMessage> receivedMessages = LrSqsClient.receiveMessages(3, 20);
        int visibilityTimeout = 10;
        for (LrSqsMessage m : receivedMessages) {
            //LrSqsClient.addMessageToChangeVisibilityBatch(m, visibilityTimeout);
            LrSqsClient.addReceiptHandleToChangeVisibilityBatch(m.receiptHandle(), visibilityTimeout);
            visibilityTimeout += 2;