Package io.atleon.aws.sqs
Class AloSqsReceiver<T>
- java.lang.Object
-
- io.atleon.aws.sqs.AloSqsReceiver<T>
-
- Type Parameters:
T- The deserialized type of SQS Message bodies
public class AloSqsReceiver<T> extends Object
A reactive receiver ofAloitems holding SQS Messages or Message bodies.Each subscription to returned
AloFluxs is backed by anSqsAsyncClient. When a subscription is terminated for any reason, the client is closed.Note that
AloDecoratorsapplied viaAloDecoratorConfig.DECORATOR_TYPES_CONFIGmust be implementations ofAloReceivedSqsMessageDecorator.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBODY_DESERIALIZER_CONFIGQualified class name of aBodyDeserializerused to convert the String payload in SQS Messages to other types.static StringCLOSE_TIMEOUT_CONFIGUpon termination of a subscription to SQS Messages, either due to errors or cancellation, this is the amount of time to wait before closing the underlying SQS Client and propagating the termination signal downstream.static StringCONFIG_PREFIXPrefix used on all AloSqsReceiver-specific configurations.static StringDELETE_BATCH_INTERVAL_CONFIGWhen delete batching is enabled, this configures the maximum amount of time a batch will remain open while waiting for it to be filled.static StringDELETE_BATCH_SIZE_CONFIGThe max number of Messages to delete in each SQS batch delete request.static StringERROR_EMISSION_TIMEOUT_CONFIGWhen negative acknowledgement results in emitting the corresponding error, this configures the timeout on successfully emitting that error.static StringMAX_IN_FLIGHT_PER_SUBSCRIPTION_CONFIGFor each subscription to SQS Messages, this is the maximum number of non-acknowledged (and non-nacknowledged) Messages.static StringMAX_MESSAGES_PER_RECEPTION_CONFIGConfigures the maximum number of messages returned by each Receive Message Request to SQS.static StringMESSAGE_ATTRIBUTES_TO_REQUEST_CONFIGList of Message Attributes to request on each message received from SQS.static StringMESSAGE_SYSTEM_ATTRIBUTES_TO_REQUEST_CONFIGList of Message System Attributes to request on each message received from SQS.static StringNACKNOWLEDGER_TYPE_CONFIGConfigures the behavior of negatively acknowledging SQS Messages.static StringNACKNOWLEDGER_TYPE_EMITstatic StringNACKNOWLEDGER_TYPE_VISIBILITY_RESETstatic StringVISIBILITY_TIMEOUT_SECONDS_CONFIGConfigures the visibility timeout (in seconds) for each received Message.static StringWAIT_TIME_SECONDS_PER_RECEPTION_CONFIGConfigures the "wait time" (in seconds) for each Receive Message Request to SQS.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> AloSqsReceiver<T>create(SqsConfigSource configSource)Creates a new AloSqsReceiver from the providedSqsConfigSourcestatic <T> AloSqsReceiver<T>from(SqsConfigSource configSource)Alias forcreate(SqsConfigSource).io.atleon.core.AloFlux<T>receiveAloBodies(String queueUrl)Creates a Publisher ofAloitems referencing deserialized SQS message bodies wrapped as anAloFlux.io.atleon.core.AloFlux<ReceivedSqsMessage<T>>receiveAloMessages(String queueUrl)
-
-
-
Field Detail
-
CONFIG_PREFIX
public static final String CONFIG_PREFIX
Prefix used on all AloSqsReceiver-specific configurations.- See Also:
- Constant Field Values
-
BODY_DESERIALIZER_CONFIG
public static final String BODY_DESERIALIZER_CONFIG
Qualified class name of aBodyDeserializerused to convert the String payload in SQS Messages to other types. You can useStringBodyDeserializerif you just want the raw String payload.- See Also:
- Constant Field Values
-
NACKNOWLEDGER_TYPE_CONFIG
public static final String NACKNOWLEDGER_TYPE_CONFIG
Configures the behavior of negatively acknowledging SQS Messages. Several simple types are available including "emit", where the associated error is emitted in to the pipeline, and "visibility_reset" which marks the message as no longer in flight and resets its visibility such that it is either re-received in the future or dead-lettered (note that when using "visibility_reset", the number of seconds the visibility is reset by is configurable throughNacknowledgerFactory.VISIBILITY_RESET_SECONDS_CONFIG, where the default is zero, leading to the message being immediately re-receivable). Any other non-predefined value is treated as a qualified class name of an implementation ofNacknowledgerFactorywhich allows more fine-grained control over what happens when an SQS Message is negatively acknowledged. Defaults to "emit".- See Also:
- Constant Field Values
-
NACKNOWLEDGER_TYPE_EMIT
public static final String NACKNOWLEDGER_TYPE_EMIT
- See Also:
- Constant Field Values
-
NACKNOWLEDGER_TYPE_VISIBILITY_RESET
public static final String NACKNOWLEDGER_TYPE_VISIBILITY_RESET
- See Also:
- Constant Field Values
-
ERROR_EMISSION_TIMEOUT_CONFIG
public static final String ERROR_EMISSION_TIMEOUT_CONFIG
When negative acknowledgement results in emitting the corresponding error, this configures the timeout on successfully emitting that error.- See Also:
- Constant Field Values
-
MAX_MESSAGES_PER_RECEPTION_CONFIG
public static final String MAX_MESSAGES_PER_RECEPTION_CONFIG
Configures the maximum number of messages returned by each Receive Message Request to SQS. Minimum is 1 and maximum is 10.- See Also:
- Constant Field Values
-
MESSAGE_ATTRIBUTES_TO_REQUEST_CONFIG
public static final String MESSAGE_ATTRIBUTES_TO_REQUEST_CONFIG
List of Message Attributes to request on each message received from SQS.- See Also:
- Constant Field Values
-
MESSAGE_SYSTEM_ATTRIBUTES_TO_REQUEST_CONFIG
public static final String MESSAGE_SYSTEM_ATTRIBUTES_TO_REQUEST_CONFIG
List of Message System Attributes to request on each message received from SQS. For a full list of available Attributes, seeMessageSystemAttributeName.- See Also:
- Constant Field Values
-
WAIT_TIME_SECONDS_PER_RECEPTION_CONFIG
public static final String WAIT_TIME_SECONDS_PER_RECEPTION_CONFIG
Configures the "wait time" (in seconds) for each Receive Message Request to SQS. Any value greater than zero activates "long polling".- See Also:
- Constant Field Values
-
VISIBILITY_TIMEOUT_SECONDS_CONFIG
public static final String VISIBILITY_TIMEOUT_SECONDS_CONFIG
Configures the visibility timeout (in seconds) for each received Message. Note that if Messages are not acknowledged for long enough, their visibility timeout may lapse and may be received again.- See Also:
- Constant Field Values
-
MAX_IN_FLIGHT_PER_SUBSCRIPTION_CONFIG
public static final String MAX_IN_FLIGHT_PER_SUBSCRIPTION_CONFIG
For each subscription to SQS Messages, this is the maximum number of non-acknowledged (and non-nacknowledged) Messages. Note that if Messages are not acknowledged for long enough, their visibility timeout may lapse and may be received again, and acknowledging the original receipt may result in an error.- See Also:
- Constant Field Values
-
DELETE_BATCH_SIZE_CONFIG
public static final String DELETE_BATCH_SIZE_CONFIG
The max number of Messages to delete in each SQS batch delete request. Batching is effectively disabled when this value <= 1. When batching is enabled (batch size > 1DELETE_BATCH_INTERVAL_CONFIGmust also be configured such that there is an upper bound on how long a batch will remain open when waiting for it to be filled.- See Also:
- Constant Field Values
-
DELETE_BATCH_INTERVAL_CONFIG
public static final String DELETE_BATCH_INTERVAL_CONFIG
When delete batching is enabled, this configures the maximum amount of time a batch will remain open while waiting for it to be filled. Specified as an ISO-8601 Duration, e.g. PT1S- See Also:
- Constant Field Values
-
CLOSE_TIMEOUT_CONFIG
public static final String CLOSE_TIMEOUT_CONFIG
Upon termination of a subscription to SQS Messages, either due to errors or cancellation, this is the amount of time to wait before closing the underlying SQS Client and propagating the termination signal downstream. Specified as ISO-8601 Duration, e.g. PT10S- See Also:
- Constant Field Values
-
-
Method Detail
-
from
public static <T> AloSqsReceiver<T> from(SqsConfigSource configSource)
Alias forcreate(SqsConfigSource). Will be deprecated in future release.
-
create
public static <T> AloSqsReceiver<T> create(SqsConfigSource configSource)
Creates a new AloSqsReceiver from the providedSqsConfigSource- Type Parameters:
T- The types of deserialized message bodies contained in received messages- Parameters:
configSource- The reactive source ofSqsConfig- Returns:
- A new AloSqsReceiver
-
receiveAloBodies
public io.atleon.core.AloFlux<T> receiveAloBodies(String queueUrl)
Creates a Publisher ofAloitems referencing deserialized SQS message bodies wrapped as anAloFlux.- Parameters:
queueUrl- The URL of an SQS queue to subscribe to- Returns:
- A Publisher of Alo items referencing deserialized SQS message bodies
-
receiveAloMessages
public io.atleon.core.AloFlux<ReceivedSqsMessage<T>> receiveAloMessages(String queueUrl)
- Parameters:
queueUrl- The URL of an SQS queue to subscribe to- Returns:
- A Publisher of Alo items referencing
ReceivedSqsMessages
-
-