Search in sources :

Example 1 with ChangeMessageVisibilityBatchRequestEntry

use of com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchRequestEntry in project aws-doc-sdk-examples by awsdocs.

the class VisibilityTimeout method changeMessageVisibilityMultiple.

// Change the visibility timeout for multiple messages.
public static void changeMessageVisibilityMultiple(String queue_url, int timeout) {
    AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
    List<ChangeMessageVisibilityBatchRequestEntry> entries = new ArrayList<ChangeMessageVisibilityBatchRequestEntry>();
    entries.add(new ChangeMessageVisibilityBatchRequestEntry("unique_id_msg1", sqs.receiveMessage(queue_url).getMessages().get(0).getReceiptHandle()).withVisibilityTimeout(timeout));
    entries.add(new ChangeMessageVisibilityBatchRequestEntry("unique_id_msg2", sqs.receiveMessage(queue_url).getMessages().get(0).getReceiptHandle()).withVisibilityTimeout(timeout + 200));
    sqs.changeMessageVisibilityBatch(queue_url, entries);
}
Also used : ArrayList(java.util.ArrayList) ChangeMessageVisibilityBatchRequestEntry(com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchRequestEntry) AmazonSQS(com.amazonaws.services.sqs.AmazonSQS)

Aggregations

AmazonSQS (com.amazonaws.services.sqs.AmazonSQS)1 ChangeMessageVisibilityBatchRequestEntry (com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchRequestEntry)1 ArrayList (java.util.ArrayList)1