// change message visibility batch to 10 sec for all messages
int i = 0;
ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest = new ChangeMessageVisibilityBatchRequest();
changeMessageVisibilityBatchRequest.setQueueUrl(queueUrl);
List<ChangeMessageVisibilityBatchRequestEntry> visibilityEntryList = new ArrayList<ChangeMessageVisibilityBatchRequestEntry>();
for (Message message : messages) {
logger.info(" Message");
logger.info(" MessageId: " + message.getMessageId());
logger.info(" ReceiptHandle: " + message.getReceiptHandle());
logger.info(" MD5OfBody: " + message.getMD5OfBody());
logger.info(" Body: " + message.getBody());
for (Entry<String, String> entry : message.getAttributes().entrySet()) {
logger.info(" Attribute");
logger.info(" Name: " + entry.getKey());
logger.info(" Value: " + entry.getValue());
}
i++;
ChangeMessageVisibilityBatchRequestEntry entry = new ChangeMessageVisibilityBatchRequestEntry(i + "", message.getReceiptHandle());
entry.setVisibilityTimeout(10);
visibilityEntryList.add(entry);
}
changeMessageVisibilityBatchRequest.setEntries(visibilityEntryList);
cqs1.changeMessageVisibilityBatch(changeMessageVisibilityBatchRequest);
// check if messages invisible
messages = new ArrayList<Message>();