LrSqsClient.addReceiptHandleToChangeVisibilityBatch
Adds a receipt handle to the current batch, to be used for the ChangeMessageVisibilityBatch request.
public static void addReceiptHandleToChangeVisibilityBatch(String receiptHandle, int visibilityTimeout)
public static void addReceiptHandleToChangeVisibilityBatch(String receiptHandle, int visibilityTimeout, String messageIdWithinBatch)
Arguments
Name | Description |
---|---|
receiptHandle | The handle contained within the LrSqsMessage. |
visibilityTimeout | The new VisibilityTimeout value. |
messageIdWithinBatch | The ID of the message in the current batch. |
Return values
This function does not return any values.
General information
A message can be identified by its receipt handle, so in this function it is used to change the visibility of a message. The messageIdWithinBatch parameter is used to identify the message status in the response.
Example
public void changeVisibility() {
LrSqsClient.initClient(region, standardQueueUrl);
LrSqsClient.initMessageBatch();
LrSqsClient.addMessageToBatch("m1");
LrSqsClient.addMessageToBatch("m2");
LrSqsClient.addMessageToBatch("m3");
LrSqsClient.addMessageToBatch("m4");
LrSqsClient.sendMessageBatch();
LrSqsMessage message1 = LrSqsClient.receiveMessage();
if (message1 != null){
LrSqsClient.changeMessageVisibility(message1.receiptHandle(), 20);
}
List <LrSqsMessage> receivedMessages = LrSqsClient.receiveMessages(3, 20);
LrSqsClient.initChangeMessageVisibilityBatch();
int visibilityTimeout = 10;
for (LrSqsMessage m : receivedMessages) {
//LrSqsClient.addMessageToChangeVisibilityBatch(m, visibilityTimeout);
LrSqsClient.addReceiptHandleToChangeVisibilityBatch(m.receiptHandle(), visibilityTimeout);
visibilityTimeout += 2;
}
LrSqsClient.changeMessageVisibilityBatch();
LrSqsClient.closeClient();
}