in src/main/java/com/amazonaws/services/sqs/SQSExecutorService.java [294:327]
protected void send() {
if (getMetadataFromTags().filter(existingMetadata -> existingMetadata.shouldNotRun(this)).isPresent()) {
if (withResponse) {
// This will immediately complete the future and cancel itself if the metadata
// already has the result set.
resultFuture = Optional.of(dedupedResultPoller.scheduleWithFixedDelay(
this::pollForResultFromMetadata, 0, 2, TimeUnit.SECONDS));
}
return;
}
SendMessageRequest request = toSendMessageRequest();
if (withResponse) {
CompletableFuture<Message> responseFuture = sqsRequester.sendMessageAndGetResponseAsync(
request, MAX_WAIT_TIME_SECONDS, TimeUnit.SECONDS);
responseFuture.whenComplete((result, exception) -> {
if (exception != null) {
setException(exception);
} else {
setFromResponse(result.getBody());
}
});
this.resultFuture = Optional.of(responseFuture);
} else {
sqs.sendMessage(request);
}
// Tag afterwards, so that the race condition will result in duplicate receives rather than
// potentially deduping all copies.
if (metadata.deduplicationID.isPresent()) {
metadata.saveToTag(sqs, queueUrl);
}
}