服务器端推送的可扩展解决方案?
我想实现一种机制,提供一个 RESTful API,允许客户端向服务器注册对某个主题的兴趣,并在注册兴趣后从服务器接收异步通知。在企业(消息传递)架构中,这称为发布/订阅“模式”。
对于桌面应用程序来说,这是很容易实现的 - 但对于 Web 应用程序来说,这被证明更加困难。
是否有(最好是开源的)框架或库允许将发布/订阅模式应用于 Web 应用程序?
服务器端技术可以采用以下任何一种语言:C、C++、PHP、Python、Ruby。
我在 Linux Ubuntu 10.0.4 上运行
I would like to implement a mechanism which will provide a RESTful API that allows a client to register interest in a subject with a sever, and receive asynchronous notifications from the server after the interest is registered. In enterprise (messaging) architecture, this is known as publish/subscribe 'pattern'.
With desktop applications, this is readily acheivable - however with web applications, it is proving to be more difficult.
is there a (preferably open source) framework or library out there that allows the publish/subscribe pattern to be applied to web applications?.
Server side technology may be in any of the following languages: C, C++, PHP, Python, Ruby.
I am running on Linux Ubuntu 10.0.4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看 pubsubhubbub 协议:http://en.wikipedia.org/wiki/PubSubHubbub
以下是该项目的来源:http://code.google.com/p/pubsubhubbub/
Have a look at the pubsubhubbub protocol: http://en.wikipedia.org/wiki/PubSubHubbub
Here is the source of the project: http://code.google.com/p/pubsubhubbub/
如果您提前知道,您将有很多订阅者(人员/应用程序)想要有关某个主题的通知,而另一方面,您将很少有不同的主题考虑拉技术。
RSS、Atom 即使使用拉取也相当成功。原因是:不需要在订阅者的服务器上进行管理,以检测谁不再感兴趣(客户端长时间离线)或拥有将所有数据发送给订阅者的机制。
使用推送,您需要在服务器上做很少的事情,而客户端每次只会拉取少量数据。
拉动会花费稍多的带宽,但无论如何它都很便宜,同时它可以为您节省大量 CPU 和软件维护费用,而这是相当昂贵的。
If you know in advance you'll have a lot of subscribers (people/applications) that want notifications on a certain subject while on other hand you'll have few different subjects consider a pull technology anyway.
RSS, Atom are quite successful even though they use pull. The reason: no need to have an administration on the server of people who are subscribed, to detect who is no longer interested (client offline for a long time) or having a mechanism to get all the data out to the subscribers.
Using push, you need to do very little on the server, while the clients will only pull a small amount of data everytime.
Pull costs slightly more bandwidth that's cheap anyway while it saves you a lot on CPU and software maintanance which is quite expensive.
我建议你看一下 STOMP 协议及其 python 客户端(我使用 < a href="http://code.google.com/p/stomppy/" rel="nofollow noreferrer">stomp.py)。这应该可以满足您的所有需求。
I suggest you take a look at STOMP protocol, and its python clients (I use stomp.py). That should suit all your needs.