LrSqsClient.addMessageToChangeVisibilityBatch
Adds a message to the current batch, to be used for the ChangeMessageVisibilityBatch request.
public static void addMessageToChangeVisibilityBatch(LrSqsMessage message, int visibilityTimeout)
public static void addMessageToChangeVisibilityBatch(LrSqsMessage message, int visibilityTimeout, String messageIdWithinBatch)
Arguments
Name | Description |
---|---|
message | The message to be added. |
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
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();
}