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 SqsTemplateBuilderbuilder()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> MessageConversionContextgetReceiveMessageConversionContext(String endpointName, Class<T> payloadClass) handleAdditionalHeaders(Map<String, Object> additionalHeaders) static SqsAsyncOperationsnewAsyncTemplate(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplateinstance with the providedSqsAsyncClient, only exposing the async methods contained inSqsAsyncOperations.static SqsOperationsnewSyncTemplate(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplateinstance with the providedSqsAsyncClient, only exposing the sync methods contained inSqsOperations.static SqsTemplatenewTemplate(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplateinstance with the providedSqsAsyncClientand 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 usingSqsReceiveOptionsand convert the payload to the provided class.Receive a message using theSqsReceiveOptionsoptions.<T> CompletableFuture<Optional<Message<T>>>receiveAsync(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Receive a message using theSqsReceiveOptionsoptions 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 usingSqsReceiveOptionsand convert the payloads to the provided class.Receive a batch of messages using theSqsReceiveOptionsoptions.<T> CompletableFuture<Collection<Message<T>>>receiveManyAsync(Consumer<SqsReceiveOptions> from, Class<T> payloadClass) Receive a batch of messages using theSqsReceiveOptionsoptions and convert the payloads to the provided class.<T> SendResult<T>send(Consumer<SqsSendOptions<T>> to) Send a message using theSqsSendOptionsoptions.<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, unwrapCompletionExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.awspring.cloud.sqs.operations.AsyncMessagingOperations
receiveAsync, receiveAsync, receiveManyAsync, receiveManyAsync, sendAsync, sendAsync, sendAsync, sendManyAsyncMethods 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 newSqsTemplateinstance with the providedSqsAsyncClientand both sync and async operations.- Parameters:
sqsAsyncClient- the client to be used by the template.- Returns:
- the
SqsTemplateinstance.
-
newSyncTemplate
public static SqsOperations newSyncTemplate(software.amazon.awssdk.services.sqs.SqsAsyncClient sqsAsyncClient) Create a newSqsTemplateinstance 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 newSqsTemplateinstance with the providedSqsAsyncClient, only exposing the async methods contained inSqsAsyncOperations.- Parameters:
sqsAsyncClient- the client.- Returns:
- the new template instance.
-
send
Description copied from interface:SqsOperationsSend a message using theSqsSendOptionsoptions.- Specified by:
sendin interfaceSqsOperations- Parameters:
to- aSqsSendOptionsconsumer.- Returns:
- The
UUIDof the message.
-
sendAsync
Description copied from interface:SqsAsyncOperationsSend a message usingSqsSendOptions.- Specified by:
sendAsyncin interfaceSqsAsyncOperations- Parameters:
to- aSqsSendOptionsconsumer.- Returns:
- a
CompletableFutureto be completed with theUUIDof the message.
-
receive
Description copied from interface:SqsOperationsReceive a message usingSqsReceiveOptions.- Specified by:
receivein interfaceSqsOperations- Parameters:
from- aSqsReceiveOptionsconsumer.- Returns:
- The message, or an empty collection if none is returned.
-
receive
Description copied from interface:SqsOperationsReceive a message usingSqsReceiveOptionsand convert the payload to the provided class.- Specified by:
receivein interfaceSqsOperations- Parameters:
from- aSqsReceiveOptionsconsumer.payloadClass- to class to convert the payload to.- Returns:
- The message, or an empty collection if none is returned.
-
receiveMany
Description copied from interface:SqsOperationsReceive a batch of messages usingSqsReceiveOptions.- Specified by:
receiveManyin interfaceSqsOperations- Parameters:
from- aSqsReceiveOptionsconsumer.- 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:SqsOperationsReceive a batch of messages usingSqsReceiveOptionsand convert the payloads to the provided class.- Specified by:
receiveManyin interfaceSqsOperations- Parameters:
from- aSqsReceiveOptionsconsumer.- Returns:
- The message, or an empty collection if none is returned.
-
receiveAsync
Description copied from interface:SqsAsyncOperationsReceive a message using theSqsReceiveOptionsoptions.- Specified by:
receiveAsyncin interfaceSqsAsyncOperations- Parameters:
from- aSqsReceiveOptionsconsumer.- Returns:
- a
CompletableFutureto 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:SqsAsyncOperationsReceive a message using theSqsReceiveOptionsoptions and convert the payload to the provided class.- Specified by:
receiveAsyncin interfaceSqsAsyncOperations- Parameters:
from- aSqsReceiveOptionsconsumer.- Returns:
- a
CompletableFutureto be completed with the message, orOptional.empty()if none is returned.
-
receiveManyAsync
Description copied from interface:SqsAsyncOperationsReceive a batch of messages using theSqsReceiveOptionsoptions.- Specified by:
receiveManyAsyncin interfaceSqsAsyncOperations- Parameters:
from- aSqsReceiveOptionsconsumer.- Returns:
- a
CompletableFutureto 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:SqsAsyncOperationsReceive a batch of messages using theSqsReceiveOptionsoptions and convert the payloads to the provided class.- Specified by:
receiveManyAsyncin interfaceSqsAsyncOperations- Parameters:
from- aSqsReceiveOptionsconsumer.- Returns:
- a
CompletableFutureto be completed with the messages, or an empty collection if none is returned.
-
preProcessMessageForSend
- Specified by:
preProcessMessageForSendin classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
preProcessMessagesForSend
protected <T> Collection<Message<T>> preProcessMessagesForSend(String endpointToUse, Collection<Message<T>> messages) - Specified by:
preProcessMessagesForSendin 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:
doSendAsyncin 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:
doSendBatchAsyncin classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
getReceiveMessageConversionContext
@Nullable protected <T> MessageConversionContext getReceiveMessageConversionContext(String endpointName, @Nullable Class<T> payloadClass) - Overrides:
getReceiveMessageConversionContextin classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
handleAdditionalHeaders
- Specified by:
handleAdditionalHeadersin classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
doAcknowledgeMessages
protected CompletableFuture<Void> doAcknowledgeMessages(String endpointName, Collection<Message<?>> messages) - Specified by:
doAcknowledgeMessagesin 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:
doReceiveAsyncin classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-
preProcessHeadersForReceive
protected Map<String,Object> preProcessHeadersForReceive(String endpointToUse, Map<String, Object> headers) - Specified by:
preProcessHeadersForReceivein classAbstractMessagingTemplate<software.amazon.awssdk.services.sqs.model.Message>
-