Class QueueAttributesManager
- java.lang.Object
-
- software.amazon.awssdk.services.sqs.internal.batchmanager.QueueAttributesManager
-
public final class QueueAttributesManager extends Object
TheQueueAttributesManager
class is responsible for managing and retrieving specific attributes of an AWS SQS queue, such as message wait time and visibility timeout. It efficiently caches these attributes to minimize redundant API calls to SQS, ensuring that the attributes are fetched only once and reused in subsequent requests.This class uses an
AtomicReference
to maintain the state of the attribute map, allowing concurrent access and handling cases where the fetching of attributes may fail. If an error occurs during the retrieval of attributes, the state is reset to allow for a fresh attempt in subsequent calls.The class provides methods to get the visibility timeout and calculate the message receive timeout, which are asynchronously retrieved and processed using
CompletableFuture
. These methods handle cancellation scenarios by cancelling the SQS request if the calling future is cancelled.This class is intended for internal use and is marked with the
SdkInternalApi
annotation.
-
-
Constructor Summary
Constructors Constructor Description QueueAttributesManager(SqsAsyncClient sqsClient, String queueUrl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Duration>
getReceiveMessageTimeout(ReceiveMessageRequest rq, Duration configuredWaitTime)
Retrieves the received message timeout based on the provided request and queue attributes.CompletableFuture<Duration>
getVisibilityTimeout()
Retrieves the visibility timeout for the queue.
-
-
-
Constructor Detail
-
QueueAttributesManager
public QueueAttributesManager(SqsAsyncClient sqsClient, String queueUrl)
-
-
Method Detail
-
getReceiveMessageTimeout
public CompletableFuture<Duration> getReceiveMessageTimeout(ReceiveMessageRequest rq, Duration configuredWaitTime)
Retrieves the received message timeout based on the provided request and queue attributes.- Parameters:
rq
- The receive message requestconfiguredWaitTime
- The configured minimum wait time- Returns:
- CompletableFuture with the calculated receive message timeout in milliseconds
-
getVisibilityTimeout
public CompletableFuture<Duration> getVisibilityTimeout()
Retrieves the visibility timeout for the queue.- Returns:
- CompletableFuture with the visibility timeout in nanoseconds
-
-