Class AloSqsReceiver<T>

  • Type Parameters:
    T - The deserialized type of SQS Message bodies

    public class AloSqsReceiver<T>
    extends Object
    A reactive receiver of Alo items holding SQS Messages or Message bodies.

    Each subscription to returned AloFluxs is backed by an SqsAsyncClient. When a subscription is terminated for any reason, the client is closed.

    Note that AloDecorators applied via AloDecoratorConfig.DECORATOR_TYPES_CONFIG must be implementations of AloReceivedSqsMessageDecorator.

    • Field Detail

      • CONFIG_PREFIX

        public static final String CONFIG_PREFIX
        Prefix used on all AloSqsReceiver-specific configurations.
        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 through NacknowledgerFactory.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 of NacknowledgerFactory which allows more fine-grained control over what happens when an SQS Message is negatively acknowledged. Defaults to "emit".
        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, see MessageSystemAttributeName.
        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 > 1 DELETE_BATCH_INTERVAL_CONFIG must 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

      • create

        public static <T> AloSqsReceiver<T> create​(SqsConfigSource configSource)
        Creates a new AloSqsReceiver from the provided SqsConfigSource
        Type Parameters:
        T - The types of deserialized message bodies contained in received messages
        Parameters:
        configSource - The reactive source of SqsConfig
        Returns:
        A new AloSqsReceiver
      • receiveAloBodies

        public io.atleon.core.AloFlux<T> receiveAloBodies​(String queueUrl)
        Creates a Publisher of Alo items referencing deserialized SQS message bodies wrapped as an AloFlux.
        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)
        Creates a Publisher of Alo items referencing ReceivedSqsMessages wrapped as an AloFlux.
        Parameters:
        queueUrl - The URL of an SQS queue to subscribe to
        Returns:
        A Publisher of Alo items referencing ReceivedSqsMessages