简体   繁体   English

如何使用AWS SQS和SNS将通知消息发送到网站?

[英]How to use AWS SQS and SNS to send notification message to website?


I have an email system in my website and as of now there is no way to show notification to user in my website. 我的网站上有一个电子邮件系统,到目前为止,无法在我的网站上向用户显示通知。 Until unless user login to email client they will not come to know that they have received a message. 除非用户登录到电子邮件客户端,否则他们将不知道自己已收到消息。


Can i accomplish this with the help of AWS SQS and SNS? 我可以借助AWS SQS和SNS来完成此任务吗? As this a website, there are many registered user. 作为这个网站,有许多注册用户。 They will be sending message to any user and say when the recipient of the email is active & logged into the website, i need to display a notification. 他们将向任何用户发送消息,并说当电子邮件的收件人处于活动状态并登录网站时,我需要显示通知。 If user is offline, i just need to show these messages on header of the page when they login. 如果用户离线,我只需要在登录时在页面标题上显示这些消息即可。 How can i do this? 我怎样才能做到这一点?

I tried creating message queue in AWS console(SQS) and Subscribed Queue to SNS Topic from SQS management console. 我尝试在AWS控制台(SQS)中创建消息队列,并从SQS管理控制台创建到SNS主题的已订阅队列 I can try sending message to this queue but i am not sure how to distribute unique user related message as notification? 我可以尝试将消息发送到此队列,但不确定如何将与用户相关的唯一消息作为通知来分发?


Please let me know if you have any suggestions for this? 如果您对此有任何建议,请告诉我。

I am using JAVA 我正在使用JAVA

Neither SNS nor SQS are good candidates for your use case. SNS和SQS都不适合您的用例。 I would recommend putting the message in some kind of data store and querying that data store on page load to determine if you should display the notification. 我建议将消息​​放入某种类型的数据存储中,并在页面加载时查询该数据存储,以确定是否应显示通知。

Options include: 选项包括:

  1. A SQL database (if you already have one, otherwise this is a pricy option) 一个SQL数据库(如果您已经拥有一个数据库,否则这是一个昂贵的选择)
  2. DynamoDB (highly available and very fast, but kind of expensive option) DynamoDB(高度可用且非常快速,但有点昂贵的选择)
  3. SimpleDB (highly available, kind of slow, and can't handle much throughput, good query capability, cheap) SimpleDB(高可用性,速度慢,并且无法处理大量吞吐量,良好的查询功能,价格便宜)
  4. S3 (highly available, kind of slow, high throughput, poor querying capabilities, cheapest option) S3(高可用性,缓慢,高吞吐量,查询能力差,最便宜的选择)

If you are not wed to the AWS stack you can take a look at Azure Table which probably meets your needs slightly better than any of those. 如果您不喜欢AWS堆栈,则可以查看Azure Table,它可能比其中任何一个稍微满足您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM