Package io.awspring.cloud.sqs.operations
Class SqsTemplate
java.lang.Object
io.awspring.cloud.sqs.operations.AbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
io.awspring.cloud.sqs.operations.SqsTemplate
- All Implemented Interfaces:
AsyncMessagingOperations
,MessagingOperations
,SqsAsyncOperations
,SqsOperations
public class SqsTemplate
extends AbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
implements SqsOperations, SqsAsyncOperations
-
Nested Class Summary
Nested classes/interfaces inherited from class io.awspring.cloud.sqs.operations.AbstractMessagingTemplate
AbstractMessagingTemplate.AbstractMessagingTemplateOptions<O extends MessagingTemplateOptions<O>>
-
Method Summary
Modifier and TypeMethodDescriptionstatic SqsTemplateBuilder
builder()
Create a newSqsTemplateBuilder
.protected CompletableFuture<Void>
doAcknowledgeMessages
(String endpointName, Collection<Message<?>> messages) protected CompletableFuture<Collection<software.amazon.awssdk.services.sqs.model.Message>>
doReceiveAsync
(String endpointName, Duration pollTimeout, Integer maxNumberOfMessages, Map<String, Object> additionalHeaders) protected <T> CompletableFuture<SendResult<T>>
doSendAsync
(String endpointName, software.amazon.awssdk.services.sqs.model.Message message, Message<T> originalMessage) protected <T> CompletableFuture<SendResult.Batch<T>>
doSendBatchAsync
(String endpointName, Collection<software.amazon.awssdk.services.sqs.model.Message> messages, Collection<Message<T>> originalMessages) protected <T> MessageConversionContext
getReceiveMessageConversionContext
(String endpointName, Class<T> payloadClass) handleAdditionalHeaders
(Map<String, Object> additionalHeaders) static SqsAsyncOperations
newAsyncTemplate
(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplate
instance with the providedSqsAsyncClient
, only exposing the async methods contained inSqsAsyncOperations
.static SqsOperations
newSyncTemplate
(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplate
instance with the providedSqsAsyncClient
, only exposing the sync methods contained inSqsOperations
.static SqsTemplate
newTemplate
(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplate
instance with the providedSqsAsyncClient
and both sync and async operations.preProcessHeadersForReceive
(String endpointToUse, Map<String, Object> headers) protected <T> Message<T>
preProcessMessageForSend
(String endpointToUse, Message<T> message) protected <T> Collection<Message<T>>
preProcessMessagesForSend
(String endpointToUse, Collection<Message<T>> messages) receive
(Consumer<SqsReceiveOptions> from) Receive a message usingSqsReceiveOptions
.receive
(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Receive a message usingSqsReceiveOptions
and convert the payload to the provided class.Receive a message using theSqsReceiveOptions
options.<T> CompletableFuture<Optional<Message<T>>>
receiveAsync
(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Receive a message using theSqsReceiveOptions
options and convert the payload to the provided class.Collection<Message<?>>
receiveMany
(Consumer<SqsReceiveOptions> from) Receive a batch of messages usingSqsReceiveOptions
.<T> Collection<Message<T>>
receiveMany
(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Receive a batch of messages usingSqsReceiveOptions
and convert the payloads to the provided class.Receive a batch of messages using theSqsReceiveOptions
options.<T> CompletableFuture<Collection<Message<T>>>
receiveManyAsync
(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Receive a batch of messages using theSqsReceiveOptions
options and convert the payloads to the provided class.<T> SendResult<T>
send
(Consumer<SqsSendOptions<T>> to) Send a message using theSqsSendOptions
options.<T> CompletableFuture<SendResult<T>>
sendAsync
(Consumer<SqsSendOptions<T>> to) Send a message usingSqsSendOptions
.Methods inherited from class io.awspring.cloud.sqs.operations.AbstractMessagingTemplate
addAdditionalHeaders, addTypeToMessages, castFromCollection, castFromOptional, getSendMessageConversionContext, receive, receive, receiveAsync, receiveAsync, receiveAsync, receiveMany, receiveMany, receiveManyAsync, receiveManyAsync, receiveManyAsync, send, send, send, sendAsync, sendAsync, sendAsync, sendMany, sendManyAsync, unwrapCompletionException
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.awspring.cloud.sqs.operations.AsyncMessagingOperations
receiveAsync, receiveAsync, receiveManyAsync, receiveManyAsync, sendAsync, sendAsync, sendAsync, sendManyAsync
Methods inherited from interface io.awspring.cloud.sqs.operations.MessagingOperations
receive, receive, receiveMany, receiveMany, send, send, send, sendMany
-
Method Details
-
builder
Create a newSqsTemplateBuilder
.- Returns:
- the builder.
-
newTemplate
public static SqsTemplate newTemplate(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplate
instance with the providedSqsAsyncClient
and both sync and async operations.- Parameters:
sqsAsyncClient
- the client to be used by the template.- Returns:
- the
SqsTemplate
instance.
-
newSyncTemplate
public static SqsOperations newSyncTemplate(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplate
instance with the providedSqsAsyncClient
, only exposing the sync methods contained inSqsOperations
.- Parameters:
sqsAsyncClient
- the client.- Returns:
- the new template instance.
-
newAsyncTemplate
public static SqsAsyncOperations newAsyncTemplate(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplate
instance with the providedSqsAsyncClient
, only exposing the async methods contained inSqsAsyncOperations
.- Parameters:
sqsAsyncClient
- the client.- Returns:
- the new template instance.
-
send
Description copied from interface:SqsOperations
Send a message using theSqsSendOptions
options.- Specified by:
send
in interfaceSqsOperations
- Parameters:
to
- aSqsSendOptions
consumer.- Returns:
- The
UUID
of the message.
-
sendAsync
Description copied from interface:SqsAsyncOperations
Send a message usingSqsSendOptions
.- Specified by:
sendAsync
in interfaceSqsAsyncOperations
- Parameters:
to
- aSqsSendOptions
consumer.- Returns:
- a
CompletableFuture
to be completed with theUUID
of the message.
-
receive
Description copied from interface:SqsOperations
Receive a message usingSqsReceiveOptions
.- Specified by:
receive
in interfaceSqsOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.- Returns:
- The message, or an empty collection if none is returned.
-
receive
Description copied from interface:SqsOperations
Receive a message usingSqsReceiveOptions
and convert the payload to the provided class.- Specified by:
receive
in interfaceSqsOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.payloadClass
- to class to convert the payload to.- Returns:
- The message, or an empty collection if none is returned.
-
receiveMany
Description copied from interface:SqsOperations
Receive a batch of messages usingSqsReceiveOptions
.- Specified by:
receiveMany
in interfaceSqsOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.- Returns:
- The message, or an empty collection if none is returned.
-
receiveMany
public <T> Collection<Message<T>> receiveMany(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Description copied from interface:SqsOperations
Receive a batch of messages usingSqsReceiveOptions
and convert the payloads to the provided class.- Specified by:
receiveMany
in interfaceSqsOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.- Returns:
- The message, or an empty collection if none is returned.
-
receiveAsync
Description copied from interface:SqsAsyncOperations
Receive a message using theSqsReceiveOptions
options.- Specified by:
receiveAsync
in interfaceSqsAsyncOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.- Returns:
- a
CompletableFuture
to be completed with the message, orOptional.empty()
if none is returned.
-
receiveAsync
public <T> CompletableFuture<Optional<Message<T>>> receiveAsync(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Description copied from interface:SqsAsyncOperations
Receive a message using theSqsReceiveOptions
options and convert the payload to the provided class.- Specified by:
receiveAsync
in interfaceSqsAsyncOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.- Returns:
- a
CompletableFuture
to be completed with the message, orOptional.empty()
if none is returned.
-
receiveManyAsync
Description copied from interface:SqsAsyncOperations
Receive a batch of messages using theSqsReceiveOptions
options.- Specified by:
receiveManyAsync
in interfaceSqsAsyncOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.- Returns:
- a
CompletableFuture
to be completed with the messages, or an empty collection if none is returned.
-
receiveManyAsync
public <T> CompletableFuture<Collection<Message<T>>> receiveManyAsync(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Description copied from interface:SqsAsyncOperations
Receive a batch of messages using theSqsReceiveOptions
options and convert the payloads to the provided class.- Specified by:
receiveManyAsync
in interfaceSqsAsyncOperations
- Parameters:
from
- aSqsReceiveOptions
consumer.- Returns:
- a
CompletableFuture
to be completed with the messages, or an empty collection if none is returned.
-
preProcessMessageForSend
- Specified by:
preProcessMessageForSend
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
preProcessMessagesForSend
protected <T> Collection<Message<T>> preProcessMessagesForSend(String endpointToUse, Collection<Message<T>> messages) - Specified by:
preProcessMessagesForSend
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
doSendAsync
protected <T> CompletableFuture<SendResult<T>> doSendAsync(String endpointName, software.amazon.awssdk.services.sqs.model.Message message, Message<T> originalMessage) - Specified by:
doSendAsync
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
doSendBatchAsync
protected <T> CompletableFuture<SendResult.Batch<T>> doSendBatchAsync(String endpointName, Collection<software.amazon.awssdk.services.sqs.model.Message> messages, Collection<Message<T>> originalMessages) - Specified by:
doSendBatchAsync
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
getReceiveMessageConversionContext
@Nullable protected <T> MessageConversionContext getReceiveMessageConversionContext(String endpointName, @Nullable Class<T> payloadClass) - Overrides:
getReceiveMessageConversionContext
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
handleAdditionalHeaders
- Specified by:
handleAdditionalHeaders
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
doAcknowledgeMessages
protected CompletableFuture<Void> doAcknowledgeMessages(String endpointName, Collection<Message<?>> messages) - Specified by:
doAcknowledgeMessages
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
doReceiveAsync
protected CompletableFuture<Collection<software.amazon.awssdk.services.sqs.model.Message>> doReceiveAsync(String endpointName, Duration pollTimeout, Integer maxNumberOfMessages, Map<String, Object> additionalHeaders) - Specified by:
doReceiveAsync
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
preProcessHeadersForReceive
protected Map<String,Object> preProcessHeadersForReceive(String endpointToUse, Map<String, Object> headers) - Specified by:
preProcessHeadersForReceive
in classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-