Closed joviegas closed 2 months ago
Still looking, giving some early feedback
Failed conditions
C Reliability Rating on New Code (required ≥ A)
See analysis details on SonarCloud
Catch issues before they fail your Quality Gate with our IDE extension SonarLint
@zoewangg merge for now since I had to raise Surface API related PR , please approve this or let me know if more comments
Raised https://github.com/aws/aws-sdk-java-v2/pull/5550 for above comments
Motivation and Context
This change is required to efficiently manage the receiving of message batches from AWS SQS, ensuring proper handling of message visibility timeout and error scenarios. It solves the problem of handling asynchronous message retrieval and processing, managing visibility timeouts, and handling exceptions during the process.
Modifications
AsyncReceiveMessageBatch
Class:ReceiveMessageRequest
based on configuration settings.ReceiveMessageCompletableFuture
Class:ReceiveQueueBuffer
Class:ResponseBatchConfiguration
Class:QueueAttributesManager
Class:Design Details
Asynchronous Handling:
AsyncReceiveMessageBatch
uses asynchronous handling for receiving messages from SQS. It leveragesCompletableFuture
to manage asynchronous operations and handle results or exceptions.Visibility Timeout Management:
visibilityDeadlineNano
.Error Handling:
AsyncReceiveMessageBatch
andQueueAttributesManager
classes handle exceptions by setting the future to complete exceptionally and resetting state where necessary.Concurrent Task Management:
ReceiveQueueBuffer
uses a concurrent queue to manage finished tasks and inflight receive message batches, ensuring thread-safe operations.QueueAttributesManager
uses anAtomicReference
to manage the cached future for fetching queue attributes, ensuring that only one request is made even under concurrent access.Adaptive Prefetching:
ResponseBatchConfiguration
supports adaptive prefetching, adjusting the number of batches based on the load and configuration.Testing
Unit tests were added for
AsyncReceiveMessageBatch
to cover:Tests for
ReceiveQueueBuffer
include:QueueAttributesManager
tests:License