in src/main/java/com/amazonaws/services/sqs/AmazonSQSVirtualQueuesClient.java [362:393]
public ReceiveMessageResult receiveMessage(ReceiveMessageRequest request) {
heartbeat();
try {
try {
Future<ReceiveMessageResult> future = receiveBuffer.receiveMessageAsync(request);
long waitTimeSeconds = Optional.ofNullable(request.getWaitTimeSeconds()).orElse(0).longValue();
// Necessary to ensure the loop terminates
if (waitTimeSeconds < 0) {
throw new IllegalArgumentException("WaitTimeSeconds cannot be negative: " + waitTimeSeconds);
}
do {
long waitTimeBeforeHeartBeat = Math.min(heartbeatIntervalSeconds, waitTimeSeconds);
try {
return future.get(waitTimeBeforeHeartBeat, TimeUnit.SECONDS);
} catch (TimeoutException e) {
// Fall through
}
heartbeat();
waitTimeSeconds -= waitTimeBeforeHeartBeat;
} while (waitTimeSeconds > 0);
} catch (ExecutionException e) {
throw (RuntimeException)e.getCause();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
// Empty receive
return new ReceiveMessageResult();
} finally {
heartbeat();
}
}