ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
receiveMessageRequest.setQueueUrl(queueUrl);
receiveMessageRequest.setMaxNumberOfMessages(10);
receiveMessageRequest.setVisibilityTimeout(15);
receiveMessageRequest.setWaitTimeSeconds(1);
ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);
count += receiveMessageResult.getMessages().size();
if (count >=1000) {
break;
}
if (System.currentTimeMillis() - ts1 > 120*1000) {
fail("only " + count + " messages found in 120 seconds");
}
}
ts1 = System.currentTimeMillis();
count = 0;
while (true) {
logger.info("event=scanning_for_revisible_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
receiveMessageRequest.setQueueUrl(queueUrl);
receiveMessageRequest.setMaxNumberOfMessages(10);
receiveMessageRequest.setWaitTimeSeconds(1);
receiveMessageRequest.setVisibilityTimeout(10);
ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);
count += receiveMessageResult.getMessages().size();
for (Message msg : receiveMessageResult.getMessages()) {
ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest(queueUrl, msg.getReceiptHandle(), 23);
cqs1.changeMessageVisibility(changeMessageVisibilityRequest);
}
if (count >=1000) {
break;
}
if (System.currentTimeMillis() - ts1 > 120*1000) {
fail("only " + count + " messages found in 120 seconds");
}
}
ts1 = System.currentTimeMillis();
count = 0;
while (true) {
logger.info("event=deleting_newly_revisible_messages found_so_far=" + count + " seconds_passed=" + ((System.currentTimeMillis()-ts1)/1000));
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
receiveMessageRequest.setQueueUrl(queueUrl);
receiveMessageRequest.setMaxNumberOfMessages(10);
receiveMessageRequest.setWaitTimeSeconds(1);
ReceiveMessageResult receiveMessageResult = cqs1.receiveMessage(receiveMessageRequest);
count += receiveMessageResult.getMessages().size();
for (Message msg : receiveMessageResult.getMessages()) {
DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest(queueUrl, msg.getReceiptHandle());
cqs1.deleteMessage(deleteMessageRequest);
}
if (count >=1000) {