Package io.awspring.cloud.sns.core
Class SnsTemplate
java.lang.Object
org.springframework.messaging.core.AbstractMessageSendingTemplate<TopicMessageChannel>
io.awspring.cloud.sns.core.SnsTemplate
- All Implemented Interfaces:
SnsOperations,DestinationResolvingMessageSendingOperations<TopicMessageChannel>,MessageSendingOperations<TopicMessageChannel>
public class SnsTemplate
extends AbstractMessageSendingTemplate<TopicMessageChannel>
implements DestinationResolvingMessageSendingOperations<TopicMessageChannel>, SnsOperations
Helper class that simplifies synchronous sending of notifications to SNS. The only mandatory fields are
SnsClient and AutoCreate boolean.- Since:
- 1.0
- Author:
- Alain Sahli, Matej Nedic, Mariusz Sondecki, Hardik Singh Behl
-
Field Summary
Fields inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate
CONVERSION_HINT_HEADER, logger -
Constructor Summary
ConstructorsConstructorDescriptionSnsTemplate(software.amazon.awssdk.services.sns.SnsClient snsClient) SnsTemplate(software.amazon.awssdk.services.sns.SnsClient snsClient, TopicArnResolver topicArnResolver, MessageConverter messageConverter) SnsTemplate(software.amazon.awssdk.services.sns.SnsClient snsClient, MessageConverter messageConverter) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChannelInterceptor(ChannelInterceptor channelInterceptor) Add aChannelInterceptorto be used byTopicMessageChannelcreated with this template.<T> voidconvertAndSend(String destination, T payload) <T> voidconvertAndSend(String destination, T payload, Map<String, Object> headers) <T> voidconvertAndSend(String destination, T payload, Map<String, Object> headers, MessagePostProcessor postProcessor) <T> voidconvertAndSend(String destination, T payload, MessagePostProcessor postProcessor) protected voiddoSend(TopicMessageChannel destination, Message<?> message) voidvoidsendNotification(Object message, String subject) Convenience method that sends a notification with the given message and subject to the destination.voidsendNotification(String topic, SnsNotification<?> notification) Sends a notification to a topic.voidsendNotification(String destinationName, Object message, String subject) Convenience method that sends a notification with the given message and subject to the destination.voidsetDefaultDestinationName(String defaultDestination) booleantopicExists(String topicArn) Checks if topic with given ARN exists.Methods inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, send, setDefaultDestination, setMessageConverterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.messaging.core.MessageSendingOperations
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, send, send
-
Constructor Details
-
SnsTemplate
public SnsTemplate(software.amazon.awssdk.services.sns.SnsClient snsClient) -
SnsTemplate
public SnsTemplate(software.amazon.awssdk.services.sns.SnsClient snsClient, @Nullable MessageConverter messageConverter) -
SnsTemplate
public SnsTemplate(software.amazon.awssdk.services.sns.SnsClient snsClient, TopicArnResolver topicArnResolver, @Nullable MessageConverter messageConverter)
-
-
Method Details
-
setDefaultDestinationName
-
doSend
- Specified by:
doSendin classAbstractMessageSendingTemplate<TopicMessageChannel>
-
send
- Specified by:
sendin interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>- Throws:
MessagingException
-
convertAndSend
- Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destination, T payload, @Nullable Map<String, Object> headers) throws MessagingException- Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destination, T payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException - Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destination, T payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) throws MessagingException- Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>- Throws:
MessagingException
-
sendNotification
Convenience method that sends a notification with the given message and subject to the destination. The subject is sent as header as defined in the SNS message JSON formats.- Parameters:
destinationName- The logical name of the destinationmessage- The message to sendsubject- The subject to send
-
sendNotification
Convenience method that sends a notification with the given message and subject to the destination. The subject is sent as header as defined in the SNS message JSON formats. The configured default destination will be used.- Parameters:
message- The message to sendsubject- The subject to send
-
addChannelInterceptor
Add aChannelInterceptorto be used byTopicMessageChannelcreated with this template. Interceptors will be applied just after TopicMessageChannel creation.- Parameters:
channelInterceptor- the message interceptor instance.
-
sendNotification
Description copied from interface:SnsOperationsSends a notification to a topic.- Specified by:
sendNotificationin interfaceSnsOperations- Parameters:
topic- - the topicnotification- - the notification
-
topicExists
Description copied from interface:SnsOperationsChecks if topic with given ARN exists.- Specified by:
topicExistsin interfaceSnsOperations- Parameters:
topicArn- - ARN of the topic- Returns:
- true if topic exists, false otherwise
-