AWS News Blog

New Features for Amazon SNS – Delivery Policies and Message Formatting

We have added two new features to Amazon SNS to give you additional control over the content and delivery of your messages. As a brief reminder, SNS allows you to create named Topics, subscribe to Topics (with delivery via email, HTTP / HTTPS, an SMS message, or to an SQS queue), and to publish messages to Topics.

SNS Delivery Policies
The SNS Delivery Policies give you options to control the delivery rate and error handling for each SNS endpoint. You can, for example, use a Delivery Policy to avoid overwhelming a particular endpoint with a sudden barrage of messages.

Delivery Policies can be set for Topics and for the endpoints associated with a particular Topic. Each Delivery Policy contains a Retry Policy and a Throttle Policy. With this release, the policies are effective for the HTTP and HTTPS Subscription types.

The Retry Policy can specify the following options:

  • minDelayTarget – Minimum delay for a retry.
  • maxDelayTarget – Maximum delay for a retry.
  • numNoDelayRetries  – Number of retries to be done with no delay (as soon as possible).
  • numMinDelayRetries – Number of retries to be done at minDelayTarget intervals before initiating the backoff function.
  • numMaxDelayRetries – Number of retries to be done at maxTargetDelay during the backoff function.
  • backoffFunction – Model for backoff between retries: Linear, Exponential, or Arithmetic.

There are default, minimum, and maxium values for each option; see the SNS documentation for more information.

The Throttle Policy can specify one option:

  • maxReceivesPerSecond – Maximum number of delivery attempts per second per Subscription.

All attempts to deliver a message are based on an “effective Delivery Policy” which combines the default policy, any policy values set for the Topic, and any policy values set for the Subscription endpoint. Values left unspecified at the Subscription level will be inherited from the Topic’s Delivery Policy and then from the default policy.

SNS Message Formatting
This feature gives you the ability to publish a message that contains content that is specific to each type of Subscription. You could, for example, send a short message to an SMS endpoint and a longer message to an email endpoint.

To use this feature, you set the new MessageStructure parameter to “json” when you call the SNS publish function.  The associated message body must contain a JSON object with a default message body and optional message bodies for other protocols:

  “default” : “Server busy.” ,
  “email”   : “Dear Jeff, your server is really busy and you should investigate. Best Regards, AWS.” ,
  “sms”     : “ALERT! Server Busy!!” ,
  “https”     : “ServerBusy”

The default entry will be used for any protocol (http and sqs in this case) that does not have an entry of its own.

— Jeff;

PS – Please feel free to share this with your friends via the Like button below!