Package io.atleon.aws.sqs
Class AloSqsSender<T>
- java.lang.Object
-
- io.atleon.aws.sqs.AloSqsSender<T>
-
- Type Parameters:
T- The un-serialized type of SQS Message bodies
- All Implemented Interfaces:
Closeable,AutoCloseable
public class AloSqsSender<T> extends Object implements Closeable
-
-
Field Summary
Fields Modifier and Type Field Description static StringBATCH_DURATION_CONFIGWhen batching is enabled, this configures the maximum amount of time a batch will remain open while waiting for it to be filled.static StringBATCH_PREFETCH_CONFIGThe number of batches to prefetch for sending.static StringBATCH_SIZE_CONFIGThe max number of Messages to send in each SQS batch send request.static StringBODY_SERIALIZER_CONFIGQualified class name ofBodySerializerimplementation used to serialize Message bodies.static StringCONFIG_PREFIXPrefix used on all AloSqsSender-specific configurations.static StringMAX_REQUESTS_IN_FLIGHT_CONFIGConfigures the maximum number of SQS Requests in flight per sent Publisher.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidclose(Object reason)Closes this sender and logs the provided reason.static <T> AloSqsSender<T>create(SqsConfigSource configSource)Creates a new AloSqsSender from the providedSqsConfigSourcestatic <T> AloSqsSender<T>from(SqsConfigSource configSource)Alias forcreate(SqsConfigSource).Function<org.reactivestreams.Publisher<io.atleon.core.Alo<T>>,io.atleon.core.AloFlux<SqsSenderResult<T>>>sendAloBodies(SqsMessageCreator<T> messageCreator, String queueUrl)Creates aFunctionthat can be used to transform a Publisher ofAloitems referencing SQS message bodies to a Publisher of Alo items referencing the result of sending each message body.io.atleon.core.AloFlux<SqsSenderResult<T>>sendAloBodies(org.reactivestreams.Publisher<io.atleon.core.Alo<T>> aloBodies, SqsMessageCreator<T> messageCreator, String queueUrl)Sends a sequence ofAloitems referencing message bodies to be populated inSqsMessages to the specified queue URL.Function<org.reactivestreams.Publisher<io.atleon.core.Alo<SqsMessage<T>>>,io.atleon.core.AloFlux<SqsSenderResult<SqsMessage<T>>>>sendAloMessages(String queueUrl)Creates aFunctionthat can be used to transform a Publisher ofAloitems referencing SQS messages to a Publisher of Alo items referencing the result of sending each message.io.atleon.core.AloFlux<SqsSenderResult<SqsMessage<T>>>sendAloMessages(org.reactivestreams.Publisher<io.atleon.core.Alo<SqsMessage<T>>> aloMessages, String queueUrl)Sends a sequence ofAloitems referencingSqsMessagesFlux<SqsSenderResult<T>>sendBodies(org.reactivestreams.Publisher<T> bodies, SqsMessageCreator<T> messageCreator, String queueUrl)Sends a sequence of message bodies to be populated inSqsMessages to the specified queue URL.Mono<SqsSenderResult<SqsMessage<T>>>sendMessage(SqsMessage<T> message, String queueUrl)Send a singleSqsMessageFlux<SqsSenderResult<SqsMessage<T>>>sendMessages(org.reactivestreams.Publisher<SqsMessage<T>> messages, String queueUrl)Sends a sequence ofSqsMessages
-
-
-
Field Detail
-
CONFIG_PREFIX
public static final String CONFIG_PREFIX
Prefix used on all AloSqsSender-specific configurations.- See Also:
- Constant Field Values
-
BODY_SERIALIZER_CONFIG
public static final String BODY_SERIALIZER_CONFIG
Qualified class name ofBodySerializerimplementation used to serialize Message bodies.- See Also:
- Constant Field Values
-
BATCH_SIZE_CONFIG
public static final String BATCH_SIZE_CONFIG
The max number of Messages to send in each SQS batch send request. Defaults to 1, meaning batching is disabled and each Message is sent in its own request. When batching is enabled (batch size > 1),BATCH_DURATION_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
-
BATCH_DURATION_CONFIG
public static final String BATCH_DURATION_CONFIG
When 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. PT0.1S- See Also:
- Constant Field Values
-
BATCH_PREFETCH_CONFIG
public static final String BATCH_PREFETCH_CONFIG
The number of batches to prefetch for sending. Note that the resulting upstream prefetch will be the product of batch size and batch prefetch.- See Also:
- Constant Field Values
-
MAX_REQUESTS_IN_FLIGHT_CONFIG
public static final String MAX_REQUESTS_IN_FLIGHT_CONFIG
Configures the maximum number of SQS Requests in flight per sent Publisher. When batching is disabled, this equates to the maximum number of Messages concurrently being sent. When batching is enabled, this equates to the maximum number batches concurrently being sent.- See Also:
- Constant Field Values
-
-
Method Detail
-
from
public static <T> AloSqsSender<T> from(SqsConfigSource configSource)
Alias forcreate(SqsConfigSource). Will be deprecated in future release.
-
create
public static <T> AloSqsSender<T> create(SqsConfigSource configSource)
Creates a new AloSqsSender from the providedSqsConfigSource- Type Parameters:
T- The type of messages bodies sent by this sender- Parameters:
configSource- The reactive source ofSqsConfig- Returns:
- A new AloSqsSender
-
sendBodies
public Flux<SqsSenderResult<T>> sendBodies(org.reactivestreams.Publisher<T> bodies, SqsMessageCreator<T> messageCreator, String queueUrl)
Sends a sequence of message bodies to be populated inSqsMessages to the specified queue URL.The output of each sent message body is an
SqsSenderResultcontaining the sent value.- Parameters:
bodies- A Publisher of SQS message bodiesmessageCreator- A factory that createsSqsMessages from message bodiesqueueUrl- URL of the queue to send messages to- Returns:
- a Publisher of the results of each sent message
-
sendMessage
public Mono<SqsSenderResult<SqsMessage<T>>> sendMessage(SqsMessage<T> message, String queueUrl)
Send a singleSqsMessage- Parameters:
message- A message to sendqueueUrl- URL of the queue to send the message to- Returns:
- A Publisher of the result of sending the message
-
sendMessages
public Flux<SqsSenderResult<SqsMessage<T>>> sendMessages(org.reactivestreams.Publisher<SqsMessage<T>> messages, String queueUrl)
Sends a sequence ofSqsMessagesThe output of each sent message is an
SqsSenderResultcontaining the sent message.- Parameters:
messages- A Publisher of messages to sendqueueUrl- URL of the queue to send messages to- Returns:
- A Publisher of items referencing the result of each sent message
-
sendAloBodies
public Function<org.reactivestreams.Publisher<io.atleon.core.Alo<T>>,io.atleon.core.AloFlux<SqsSenderResult<T>>> sendAloBodies(SqsMessageCreator<T> messageCreator, String queueUrl)
Creates aFunctionthat can be used to transform a Publisher ofAloitems referencing SQS message bodies to a Publisher of Alo items referencing the result of sending each message body. SeesendAloBodies(Publisher, SqsMessageCreator, String)for further information.- Parameters:
messageCreator- A factory that createsSqsMessages from message bodiesqueueUrl- URL of the queue to send messages to- Returns:
- A
Functionuseful for Publisher transformations
-
sendAloBodies
public io.atleon.core.AloFlux<SqsSenderResult<T>> sendAloBodies(org.reactivestreams.Publisher<io.atleon.core.Alo<T>> aloBodies, SqsMessageCreator<T> messageCreator, String queueUrl)
Sends a sequence ofAloitems referencing message bodies to be populated inSqsMessages to the specified queue URL.The output of each sent message body is an
SqsSenderResultcontaining the sent value. Each emitted item is anAloitem referencing anSqsSenderResultand must be acknowledged or nacknowledged such that its processing can be marked complete at the origin of the message.- Parameters:
aloBodies- A Publisher of Alo items referencing SQS message bodiesmessageCreator- A factory that createsSqsMessages from message bodiesqueueUrl- URL of the queue to send messages to- Returns:
- a Publisher of Alo items referencing the result of each sent message
-
sendAloMessages
public Function<org.reactivestreams.Publisher<io.atleon.core.Alo<SqsMessage<T>>>,io.atleon.core.AloFlux<SqsSenderResult<SqsMessage<T>>>> sendAloMessages(String queueUrl)
Creates aFunctionthat can be used to transform a Publisher ofAloitems referencing SQS messages to a Publisher of Alo items referencing the result of sending each message. SeesendAloMessages(Publisher, String)for further information.- Parameters:
queueUrl- URL of the queue to send messages to- Returns:
- A
Functionuseful for Publisher transformations
-
sendAloMessages
public io.atleon.core.AloFlux<SqsSenderResult<SqsMessage<T>>> sendAloMessages(org.reactivestreams.Publisher<io.atleon.core.Alo<SqsMessage<T>>> aloMessages, String queueUrl)
Sends a sequence ofAloitems referencingSqsMessagesThe output of each sent message is an
SqsSenderResultcontaining the sent message. Each emitted item is anAloitem referencing aSqsSenderResultand must be acknowledged or nacknowledged such that its processing can be marked complete at the origin of the message.- Parameters:
aloMessages- A Publisher of Alo items referencing messages to sendqueueUrl- URL of the queue to send messages to- Returns:
- A Publisher of Alo items referencing the result of each sent message
-
close
public void close(Object reason)
Closes this sender and logs the provided reason.- Parameters:
reason- The reason this sender is being closed
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-