发布/订阅REST-HTTP简单协议Web服务体系结构? [英] Publish/subscribe REST-HTTP Simple Protocol web services architecture?
问题描述
我正在向您提出有关建筑"场景的建议:
I'm asking your sugegstions about an "architectural" scenario:
我正在寻找一种最简单的发布/订阅体系结构,以使两个脱钩的服务器在Internet上进行通话,共享稀疏"但实时"的消息/事件.
I'd looking for a simplest publish/subscribe architecture to let talk two decoupled servers over on internet, sharing "sparse" but "real-time" messages/events.
让我解释一下:
-
发布者: 是服务器( http://www.server.com )生成某种事件(例如) events ==在电子商务网站上订购数据).
The PUBLISHER: Is a server (http://www.server.com) that generate some sort of events (by example events==ORDERS data on a e-commerce website).
订户(一个或多个): 是可以订阅以接收ORDERS事件的客户端"( http://www.client.com ).
SUBSCRIBERS (one or more): Are "clients" that can subscribe to receive ORDERS events (http://www.client.com).
在现实生活中,发布者是由第三方开发(在Rails中)的服务器.目前,我可以使用简单的轮询"策略将其获得订单",这是每N秒调用GET/new_orders的接口.
In real life case, the publisher is a server developed (in Rails) by a third party. At the moment I can interface it getting "orders" with a plain "polling" strategy: every N seconds I call a GET /new_orders.
不好!
所以我正在考虑使用一种REST方法更好的pub/sub体系结构,其中Publisher共享EVENTS资源:
So I'm thinking about a bit better pub/sub architecture with a REST approach where Publisher share the EVENTS recources:
-
客户端订阅以接收事件,从而向发布者提供 将来会调用"URL HOOK"(例如: http://www.client.com/orders).
The client Subscribe to receive events, supplying to the Publisher a "URL HOOK" to be call in future (by example: http://www.client.com/orders).
发布者,当有新事件(==订单)时,只需HTTP POST数据 到客户端先前提供的客户端URL挂钩.
The Publisher, when there is a new event (== order) simply HTTP POST data to client URL Hook previously supplyied by Client.
有道理吗?还是我正在重新发明轮子?
Make sense ? Or I'm reinventing the wheel ?
顺便说一句,我使用Ruby语言进行开发,而且我知道Faye是发布/订阅消息系统. 但是您如何看待这个简单的协议(我想仅使用Ruby/Sinatra来实现客户端)? (请参见图片 1 )
BTW, I develop in Ruby language and, I'm aware of pub/sub messaging systems as Faye. but what do you think about this simple protocol (I'd like implment client-side simply with Ruby/Sinatra) ? (see image 1)
任何建议欢迎.非常感谢
Any suggestion welcome. Thanks a lot
乔治(Giorgio)
Giorgio
推荐答案
任何时候您都可以让第三方发布POST到您的 Web服务,这是一件好事!很多时候,这不是一种选择,您必须采用某种效率低下的轮询架构.我认为您的架构图没有任何问题.
Any time you can get a third-party to POST to your web services, it's a good thing! A lot of the time, this isn't an option and you must resort to some kind of inefficient polling architecture. I don't think there's anything wrong with your architecture diagram.
您始终可以使用第三方消息传递系统(Amazon SQS,RabbitMQ等),但是除非您需要
You can always use third-party messaging systems (Amazon SQS, RabbitMQ, etc.) but there's not much reason to do that unless you need durable messaging.
如果您担心HTTP流量(特别是对Web服务的调用次数),则还可以鼓励第三方支持批处理POST.也许他们只能每5分钟向订户发送一次新订单,作为批处理的一部分.
If you're concerned about HTTP traffic--specifically, the number of calls being made to your web service--you could also encourage the third-party to support batch POSTing. Perhaps they can only send subscribers new orders every 5 minutes as part of a batch.
这篇关于发布/订阅REST-HTTP简单协议Web服务体系结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!