亚马逊SNS使用Java来推动主题 [英] Amazon SNS to push topic using Java

查看:90
本文介绍了亚马逊SNS使用Java来推动主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现我的基于Java的网站推送通知(使用Struts 1.x的)。我们的目标是使类似的东西到什么#1和其他网站都该通知时,他们得到消息的实时用户。

I'm trying to implement push notifications on my Java-based website(Using Struts 1.x). The goal is to make something similiar to what Stackoverflow and other sites have which notify a user in real-time when they get messages.

我使用MySQL作为我的数据库,Apache作为我的服务器,并正在使用亚马逊SNS作为,因为这些通知的框架考虑是什么服务,似乎是打算。

I'm using mysql as my database, Apache as my server, and am considering using Amazon-SNS as the framework for these notifications since that is what that service seems to be intended for.

推荐答案

在一个网站,不,这不是SNS确实做到了。

On a "web site," no, that isn't what SNS really does.

SNS有两种不同的操作模式:

SNS has two different modes of operation:

  • 在主题 - 发送广播通知网络相结合的通过HTTP服务器的(而不是浏览器)(S),电子邮件地址,SQS队列和短信设备(短信),有确认他们订阅的SNS主题
  • 在移动推 - (不是直接到Web浏览器),你写的移动应用程序直接发送寻址的推送通知
  • "topics" -- sending broadcast notifications to a combination of web servers (not browsers) over http(s), email addresses, SQS queues, and SMS devices (text messages), that have confirmed their subscription to the SNS topic
  • "mobile push" -- sending addressable push notifications directly to mobile apps you write (not to the web browsers directly)

有关到浏览器的实时通知,看看在页面的源代码你看,现在的暗示它是如何做的:

For real-time notifications to browsers, take a look at the source of the page you're looking at right now for a hint of how it's done:

<script type="text/javascript">
StackExchange.ready(function () {
    StackExchange.realtime.init('wss://qa.sockets.stackexchange.com,ws://qa.sockets.stackexchange.com');
    StackExchange.realtime.subscribeToInboxNotifications();
    StackExchange.realtime.subscribeToReputationNotifications('1');
    StackExchange.realtime.subscribeToTopBarNotifications('1');
});
</script>

这看起来像一个的WebSocket 连接,确定了 WSS:/ / (用 HTTPS对比:// )。有各种各样的WebSockets的实现的,各种语言,允许一个组件在你身边与在浏览器中运行的JavaScript交互,我会认为这是最接近的标准机制,以现代的网络推送通知浏览器。

That looks like a websocket connection, identified by wss:// (contrast with https://). There are a variety of implementations of websockets, in various languages, that allow a component on your side to interact with the javascript running on the browser, and I would suggest that this is the closest thing to a standard mechanism for push notifications to modern web browsers.

SNS并没有一个功能集,提供这种集成到浏览器,虽然它可能是一个你可以使用内部中继从您的应用程序服务器的消息到你的WebSocket网关(S),因为SNS可以提供应用服务器和网关,或广播消息给多个网关,如果这就是你如何实现它的能力之间的短期缓冲......大概是这样的好处是,它会prevent应用服务器被如果网关超载或脱机的不利影响。理论上的WebSockets可以由应用服务器自身被终止,因为它们开始他们通过HTTP连接,但更长的寿命的典型的websocket连接的相比,一个http请求可以使这个坏组合

SNS does not have a feature-set that offers this kind of integration to the browser, though it might be something you could use internally to relay messages from your application server to your websocket gateway(s), since SNS could provide a short-term buffer between the app server and the gateway, or the ability to broadcast a message to multiple gateways, if that's how you implemented it... the advantage of something like this would be that it would prevent the app server from being adversely impacted if the gateway were overloaded or offline. Theoretically websockets can be terminated by the application server itself, since they begin their connection over HTTP, but the longer life of a typical websocket connection compared to an http request can make this a bad combination.

这篇关于亚马逊SNS使用Java来推动主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆