Can I use Amazon SQS as a wait queue before sending to SNS?

My system runs in the Amazon autoscale group, and one feature allows the user to send messages to users, and I can use the following use case.

  • A new message is sent in my application between users.
  • The user notification email is thrown into the queue with a delay of 60 seconds. This delay allows time for the real-time chat client (faye / angularjs) to see the message and mark it as viewed.
  • After the delay, the message is picked up, the β€œread” status is checked, and if the client has not been read by the client, an email is sent.

Initially, I was going to use cronjob on each polling server server in the message queue, however it seems to me that it would be more efficient to use SNS to call some kind of email sending endpoint (possibly in Lambda).

I don't see any way to poll SQS SNS, can anyone suggest how this can be done? Essentially, I want a delayed SNS so as not to spam someone in a live chat with email alerts.

thanks

+7
source share
2 answers

Unfortunately, this is not yet available out of the box. The missing part is the creation of Amazon SNS notifications about the arrival / visibility of messages in the Amazon SQS queue, whether using push notifications (similar to Amazon S3 notifications or using surveys similar to Amazon Kinesis subscriptions (for more details see Pull / Push event models). difference), which would allow you to directly connect the AWS Lambda function to the corresponding events of the SQS delay queue , see, for example:

In doing so, you can circumvent these limitations in several ways, for example:

The AWS Lambda team has delivered many / most of the similar requests in the last two months, so I expect them to offer both SQS event handling and the planned Lambda features throughout the year.

+5
source

At the beginning of 2019, this problem can be solved in several different ways:

Since SNS has a theme limit of 100,000 for each account , I would recommend using Amazon SES to send emails (62,000 free emails per month can help you make decisions about the cost of implementation).

0
source

All Articles