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>();
receiveMessageRequest.setMaxNumberOfMessages(10);
messages = cqs1.receiveMessage(receiveMessageRequest).getMessages();
assertTrue("Expected 0 messages, received " + messages.size(), messages.size() == 0);
Thread.sleep(11000);
// check if messages revisible
messages = null;
receiveMessageRequest.setMaxNumberOfMessages(10);
receiveMessageRequest.setWaitTimeSeconds(1);
while (messages == null || messages.size() == 0) {
logger.info("event=scanning_for_messages");
messages = cqs1.receiveMessage(receiveMessageRequest).getMessages();
}
assertTrue("Expected 5 messages, received " + messages.size(), messages.size() == 5);
// delete messages
List<DeleteMessageBatchRequestEntry> deleteEntryList = new ArrayList<DeleteMessageBatchRequestEntry>();
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++;
deleteEntryList.add(new DeleteMessageBatchRequestEntry(i+"", message.getReceiptHandle()));