简体   繁体   English

WCF REST推送流服务

[英]WCF REST Push Stream Service

Need some help figuring out what I am looking for. 需要一些帮助来弄清楚我在寻找什么。 Basically, I need a service in which the Server dumps a bunch of XML into a stream (over a period of time) and every time the dump occurs N number of clients read the dump. 基本上,我需要一种服务,其中Server将一堆XML转储到流中(在一段时间内),每次转储发生时, N个客户端读取转储。

Example : Every time one of a 1000 stocks goes up by 5 cents, the service dumps some XML into a stream. 示例 :每当1000股票中的一个上涨5分时,该服务会将一些XML转储到流中。 The connecting applications grab the information from the stream. 连接应用程序从流中获取信息。

I don't think the connection will ever close, as there needs to be something reading the stream for new data. 我认为连接不会关闭,因为需要读取新数据流的内容。

This needs to adhere to WCF REST standards, is there something out there that I'm looking for? 这需要遵循WCF REST标准,那里有什么我正在寻找的东西吗?
In the end, it's just a non-stop stream of data. 最后,它只是一个不间断的数据流。

Update: Looks like the service needs to be a multi-part/mixed content type. 更新:看起来服务需要是多部分/混合内容类型。

An application I'm working on has a similar architecture, and I'm planning to use SignalR to push updates to clients, using long-polling techniques. 我正在开发的应用程序具有类似的体系结构,我计划使用SignalR来使用长轮询技术将更新推送到客户端。 I haven't implemented it yet, so I can't swear it will work for you, but their documentation seems promising: Update: I have implemented this now, and it works very well. 我还没有实现它,所以我不能发誓它会对你有用,但是他们的文档看起来很有希望: 更新:我现在已经实现了它,它运行得很好。

Pushing data from the server to the client (not just browser clients) has always been a tough problem. 将数据从服务器推送到客户端(不仅仅是浏览器客户端)始终是一个棘手的问题。 SignalR makes it dead easy and handles all the heavy lifting for you. SignalR让它变得简单易行并为您处理所有繁重的工作。

Scott Hansleman has a good blog on the subject and there is a useful article (involving WCF, REST, and SignalR) here: http://www.codeproject.com/Articles/324841/EventBroker Scott Hansleman有一个关于这个主题的好博客 ,这里有一篇有用的文章(涉及WCF,REST和SignalR): http//www.codeproject.com/Articles/324841/EventBroker

Instead of using WCF, have you look into ASP.NET MVC WebAPI ? 您是否可以查看ASP.NET MVC WebAPI而不是使用WCF?

For more information about using PushStreamContent in WebAPI, Henrik has a nice blog with example (under the heading 'Push Content'). 有关在WebAPI中使用PushStreamContent的更多信息,Henrik有一个很好的博客示例(在“推送内容”标题下)。

Have you considered archived Atom feeds ? 您是否考虑过归档的Atom供稿 They are 100% RESTful ( hypermedia controls and all ) and most importantly, they are very scalable . 它们是100%RESTful( 超媒体控件和所有 ),最重要的是, 它们具有很高的可扩展性

Specifically, the archive documents never change, so you can set a cache expiry of 1 year or more. 具体来说,归档文档永远不会更改,因此您可以将缓存过期设置为1年或更长时间。 The subscription document is where all the newest events go and is constantly changing, but with the appropriate HTTP caching headers, you can make so you return 304 Not Modified if nothing has changed between each client request. 订阅文档是所有最新事件发生并且不断变化的地方,但是如果使用适当的HTTP缓存标头,您可以返回304 Not Modified,如果每个客户端请求之间没有任何更改。 Also, if you service has a natural time resolution, you can set the max-age to take advantage of that. 此外,如果您的服务具有自然时间分辨率,您可以设置max-age以利用它。 For instance, if you data has a 20min resolution, you could include the following header in the subscription document response: 例如,如果数据的分辨率为20分钟,则可以在订阅文档响应中包含以下标题:

Cache-Control: max-age=1200

that way you can let you caches do most of the heaving lifting and the clients can poll the subscription document as often as they like, without bringing your service to it's knees. 通过这种方式,您可以让缓存完成大部分的提升,客户可以随时轮询订阅文档,而不会让您的服务瘫痪。

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

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