Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 17, 2024 01:39 pm GMT

EDA Messaging: SNS Topic Subscriptions Filter Demo

This is the blog post to the demo application on EDA PubSub messaging with an Amazon Simple Notification Service topic with multiple subscriptions. This post examines some of the features, capabilities, and limitations of message publishing with SNS.

Amazon SNS

Amazon SNS is a fully managed service for publishing messages to multiple subscribers through an SNS topic. The relationship is one-to-many, one topic with many subscriptions. SNS supports application-to-application messaging and application-to-person notifications.

Standard SNS Topic

Topics of Standard type are fine when the message delivery order does not matter and the possibility of duplicate message delivery does not impact the expected outcome of your application.

Publishing messages

Message size is limited to a maximum of 256 KB. For larger messages under a maximum of 2 GB, the Amazon SNS Extended Client libraries are available to save these to an S3 bucket and publish just their references to the topic.

Message attributes are where you can provide custom, structured metadata in your messages.

Subscription Filter Policy

A filter policy on a subscription allows that subscriber to receive a subset of all the messages available. A filter policy is a JSON object, consisting of the property names and values, along with filtering operators, that will define what will make a match.

Demo applicationin CDK Python

This is the GitHub repo of my demo application:
https://github.com/evefonwu/pubsub-sns-topic-subscriptions-filter

The codebase consists of the following:

  1. An SNS Topic with two email subscriptions.
  2. A demo email subscription without a filter policy.
  3. A welcome_team email subscription with a filter policy to allow only 'demo' application, 'account_created' messages.
  4. A publisher with a FunctionURL publishes a hello message to the topic.
  5. A welcome_publisher with a FunctionURL publishes a 'demo' application, 'account_created' message to the topic.

Once deployed, the CDK will output the Function URLs of the two publishers.

Open email inboxes and confirm the email subscriptions to the SNS topic.

Access both URLs to trigger sending messages to the SNS topic.

The demo subscription receives both emails since it does not have a filter policy. The welcome_team subscription receives only the message that matches its filter policy.

Documentation Links

AWS SNS Documentation:
https://docs.aws.amazon.com/sns/latest/dg/welcome.html

AWS SNS Message Filtering Documentation:
https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html


Original Link: https://dev.to/evefonwu/eda-messaging-sns-topic-subscriptions-filter-demo-5cf8

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To