Publish to SNS
The Publish action sends a message to all of a topic’s subscribed endpoints. A returned messageId indicates that the message was saved and Amazon SNS will attempt to deliver it to the topic’s subscribers shortly. The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected. Lets see how we can publish to SNS
Create project in Anypoint studio and configure the listener to trigger the flow
Drag and drop publish operation and provide the connector configuration
Topic ARN: The topic you want to publish to.
To get the topic arn you can get the arn value from Amazon SNS Service as shown below
Message:The message you want to send to the topic.
Subject:Optional parameter to use as the “Subject” line when the message is delivered to email endpoints
Create the transform message to send the message to subscribed endpoint as a string value
%dw 2.0 output application/json --- '{ "EmployeeId":1234, "EmployeeName":"John", "EmployeeEmail":"Dey" }'
See below url to check when we need to send the string message and when as a json object
https://docs.aws.amazon.com/sns/latest/api/API_Publish.html
Create the transform message to send messageid
%dw 2.0 output application/json --- payload
Deploy the project and trigger to test from soapui
You can see the message received on endpoint as shown below
Sample application : publishmessagetosnstopic sample
Soap ui sample project: PublishtoSnsTopic-soapui-project
How do we achieve fail over for SNS publish? For e.g. while publishing to any queue in JMS, if it fails for some reason, it creates DLQ and message is persisted in DLQ, thus we don’t loose the message. Is there any such mechanism present for SNS?