Dave
Dave

Reputation: 1062

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.

Example: Every time one of a 1000 stocks goes up by 5 cents, the service dumps some XML into a stream. 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?
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.

Upvotes: 12

Views: 1608

Answers (3)

Jude Fisher
Jude Fisher

Reputation: 11294

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. 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.

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

Upvotes: 6

Tom Howard
Tom Howard

Reputation: 6687

Have you considered archived Atom feeds? They are 100% RESTful (hypermedia controls and all) and most importantly, they are very scalable.

Specifically, the archive documents never change, so you can set a cache expiry of 1 year or more. 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. Also, if you service has a natural time resolution, you can set the max-age to take advantage of that. For instance, if you data has a 20min resolution, you could include the following header in the subscription document response:

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.

Upvotes: 2

Maggie Ying
Maggie Ying

Reputation: 10175

Instead of using WCF, have you look into ASP.NET MVC WebAPI?

For more information about using PushStreamContent in WebAPI, Henrik has a nice blog with example (under the heading 'Push Content').

Upvotes: 3

Related Questions