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
-
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 TypeMethodDescription<T> void
convertAndSend
(String destination, T payload) <T> void
convertAndSend
(String destination, T payload, Map<String, Object> headers) <T> void
convertAndSend
(String destination, T payload, Map<String, Object> headers, MessagePostProcessor postProcessor) <T> void
convertAndSend
(String destination, T payload, MessagePostProcessor postProcessor) protected void
doSend
(TopicMessageChannel destination, Message<?> message) void
void
sendNotification
(Object message, String subject) Convenience method that sends a notification with the given message and subject to the destination.void
sendNotification
(String topic, SnsNotification<?> notification) Sends a notification to a topic.void
sendNotification
(String destinationName, Object message, String subject) Convenience method that sends a notification with the given message and subject to the destination.void
setDefaultDestinationName
(String defaultDestination) Methods inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, send, setDefaultDestination, setMessageConverter
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
doSend
in classAbstractMessageSendingTemplate<TopicMessageChannel>
-
send
- Specified by:
send
in interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>
- Throws:
MessagingException
-
convertAndSend
- Specified by:
convertAndSend
in interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>
- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destination, T payload, @Nullable Map<String, Object> headers) throws MessagingException- Specified by:
convertAndSend
in interfaceDestinationResolvingMessageSendingOperations<TopicMessageChannel>
- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destination, T payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException - Specified by:
convertAndSend
in 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:
convertAndSend
in 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
-
sendNotification
Description copied from interface:SnsOperations
Sends a notification to a topic.- Specified by:
sendNotification
in interfaceSnsOperations
- Parameters:
topic
- - the topicnotification
- - the notification
-