M
- type Message
or AsynchronousMessage
. The Message.getRecipients()
is phone numbersM
- as Message
or AsynchronousMessage
; of recipient type String (phone number) and Message.getPayload()
as Text to send
Note: The recipient # derivation logic should not be left to this adapter-level impl hence its kept String as any contact/user derivation logic should be anyway external
before message is created. Similarly a message can't only be a text at the end so any dynamic text logic ambitions are also best left out.public class AmazonSNSDispatcher<M extends SMS> extends Object implements BulkDispatcher<M>
Transformer
AsynchronousMessage
Constructor and Description |
---|
AmazonSNSDispatcher(AmazonSNSAuthenticationDetails auth,
MessageDeliveryAttributes arnAccess,
com.amazonaws.auth.BasicAWSCredentials awsCredentials,
String regionsName) |
Modifier and Type | Method and Description |
---|---|
void |
broadcast(M msg)
Single Message Sent to Multiple Recipients
|
void |
close()
Shuts down the SNS client object, releasing any resources that might be held open.
|
void |
dispatch(List<M> message)
Sends nth Message to the nth Recipient
|
void |
dispatch(M msg)
Sends single message to single recipient
Publish Message to a Single Number |
MessageType |
evaluateType(Priority priority,
Boolean isDirectMessage)
Set Type of Message.
|
protected Map<String,com.amazonaws.services.sns.model.MessageAttributeValue> |
generateSMSAttributesAndUpdateDerivedTypes(M msg)
Use AmazonSNSAuthenticationDetails object to create a Map of Default SMS attributes and also update
SMS.getSettings() .typeRefer to for Setting SMS attributes |
MessageDeliveryAttributes |
getArnAccess()
Attribute Details for Message Delivery Reports
|
AmazonSNSAuthenticationDetails |
getAuthentication()
Stores the Authentication Details of the user
|
com.amazonaws.auth.AWSCredentials |
getAwsCredentials()
Credentials required to init a
AmazonSNSClientClient |
String |
getDefaultCountryCode()
Country Code of the recipient
|
int |
getMessagePriorityThresholdSecs()
If less than this amount of seconds then treat message as priority.
Priority = MessageType.TRANSACTIONAL else MessageType.PROMOTIONAL |
com.amazonaws.regions.Regions |
getRegions()
Enumeration of region names
|
com.amazonaws.services.sns.AmazonSNSClient |
getSnsClient()
Client for accessing Amazon SNS.
|
void |
init() |
boolean |
isFailFast()
Decides whether to continue with execution of code when a error occurs or simply throw the error
|
void |
publishToSingleNumber(Message message,
Map<String,com.amazonaws.services.sns.model.MessageAttributeValue> smsAttributes)
Sends One message to One recipient
|
void |
setArnAccess(MessageDeliveryAttributes arnAccess)
Attribute Details for Message Delivery Reports
|
void |
setAuthentication(AmazonSNSAuthenticationDetails authentication)
Stores the Authentication Details of the user
|
void |
setAwsCredentials(com.amazonaws.auth.AWSCredentials awsCredentials)
Credentials required to init a
AmazonSNSClientClient |
void |
setDefaultCountryCode(String defaultCountryCode)
Country Code of the recipient
|
void |
setFailFast(boolean failFast)
Decides whether to continue with execution of code when a error occurs or simply throw the error
|
void |
setMessagePriorityThresholdSecs(int messagePriorityThresholdSecs)
If less than this amount of seconds then treat message as priority.
Priority = MessageType.TRANSACTIONAL else MessageType.PROMOTIONAL |
void |
setRegions(com.amazonaws.regions.Regions regions)
Enumeration of region names
|
void |
setSnsClient(com.amazonaws.services.sns.AmazonSNSClient snsClient)
Client for accessing Amazon SNS.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
accept, getSettings, transform
public AmazonSNSDispatcher(AmazonSNSAuthenticationDetails auth, MessageDeliveryAttributes arnAccess, com.amazonaws.auth.BasicAWSCredentials awsCredentials, String regionsName)
auth
- : Authentication Details to be used for sending the messagesnsCl
- : client to be used for accessing SNSreg
- : region to be used for the sms
@PostConstruct public void init()
public void dispatch(M msg)
dispatch
in interface GenericDispatcher<M extends SMS>
public void broadcast(M msg) throws Exception, PartialTransactionException
broadcast
in interface BulkDispatcher<M extends SMS>
M
- type Message
PartialTransactionException
- in case of partial failures. Where PartialTransactionException.getFailed()
are of type PayLoadException
Exception
- which can be of any type from AmazonSNSClient.publish(PublishRequest)
AmazonSNSClient.publish(PublishRequest)
,
Publish Message to a Multiple Phone Numberspublic void dispatch(List<M> message) throws PartialTransactionException
dispatch
in interface BulkDispatcher<M extends SMS>
M
- type Message
PartialTransactionException.
- Where PartialTransactionException.getFailed()
are of type PayLoadException
PartialTransactionException
public void publishToSingleNumber(Message message, Map<String,com.amazonaws.services.sns.model.MessageAttributeValue> smsAttributes)
M
- type Message
smsAttributes
- : Attributes of Message to be sentPartialTransactionException
- in case of partial failuresException
- which can be of any type from AmazonSNSClient.publish(PublishRequest)
AmazonSNSClient.publish(PublishRequest)
public MessageType evaluateType(Priority priority, Boolean isDirectMessage)
priority
- : priority of MessageisDirectMessage
- : Whether the message is of Direct typeprotected Map<String,com.amazonaws.services.sns.model.MessageAttributeValue> generateSMSAttributesAndUpdateDerivedTypes(M msg)
SMS.getSettings()
.typesettings
- as AmazonMessageSettings
, nullable false
Details regarding SMS AttributesMap
of key and value as MessageAttributeValue
, nullablepublic void close()
AmazonWebServiceClient.shutdown()
public AmazonSNSAuthenticationDetails getAuthentication()
AmazonSNSAuthenticationDetails
public void setAuthentication(AmazonSNSAuthenticationDetails authentication)
AmazonSNSAuthenticationDetails
public com.amazonaws.services.sns.AmazonSNSClient getSnsClient()
public void setSnsClient(com.amazonaws.services.sns.AmazonSNSClient snsClient)
public com.amazonaws.regions.Regions getRegions()
public void setRegions(com.amazonaws.regions.Regions regions)
public String getDefaultCountryCode()
public void setDefaultCountryCode(String defaultCountryCode)
public void setFailFast(boolean failFast)
public boolean isFailFast()
public int getMessagePriorityThresholdSecs()
MessageType.TRANSACTIONAL
else MessageType.PROMOTIONAL
evaluateType(Priority, Boolean)
public void setMessagePriorityThresholdSecs(int messagePriorityThresholdSecs)
MessageType.TRANSACTIONAL
else MessageType.PROMOTIONAL
evaluateType(Priority, Boolean)
public MessageDeliveryAttributes getArnAccess()
MessageDeliveryAttributes
public void setArnAccess(MessageDeliveryAttributes arnAccess)
MessageDeliveryAttributes
public com.amazonaws.auth.AWSCredentials getAwsCredentials()
AmazonSNSClientClient
AWSCredentials
public void setAwsCredentials(com.amazonaws.auth.AWSCredentials awsCredentials)
AmazonSNSClientClient
AWSCredentials
Copyright © 2018. All rights reserved.