I work in finance, and at the moment work in the Foreign Exchange (FX) space, where we have lots of requirements that involve streaming of various things, such as:
- Rates
- Trades
- Other financial instruments
Historically, what we would have done to accommodate these requirements was to use sockets and push our own data (usually JSON or XML) down the wire, and then had some quite knarly listeners above that, where each listener would want some slightly different view of the original streaming data.
Thing is, time has never stood still in the world of software development, and new things come out all the time, literally every other day, a new framework comes along that helps improve what came before it in some way or another.
One particular thing that I think a lot of people actually misunderstood was Reactive Extensions RX, which in fairness has been around a while now. I think a lot of people think of RX as LINQ to events, which it does have. However the truth is that RX is a superb framework for creating streaming applications and the more you get into RX, the more you tend to see everything as a stream, from and event, down to picking a file or a ICommand.Execute
in a ViewModel
say.
RX comes with many many tools in its arsenal, such as:
- 2 core interfaces
IObservable
/ IObserver
- Lots of LINQ like extension methods for
IObservable
- Time / window based operations (LINQ doesn’t really have these)
- Concurrency schedulers
- Stream error handling controls (
Catch
, etc.) - Ability to create
IObservable
from a great many other things, such as
IEnumerable
Task
- Events
IObservable
Factories
I personally feel that a lot of people could make use of RX to great gain, if they were to put in the time to learn about it, a bit more.
There is also another great library from Microsoft which facilitates push based technology, namely SignalR. Quite a lot has been written about SignalR, but you rarely see that from a desktop point of view.
Most people would probably associate a SignalR Hub with a web site, but there are various ways you can use SignalR, which also make it a good choice for desktop (ie non web) development. This is possible thanks to the SignalR OWIN hosting API, such that you can self host a SignalR Hub. There is also a .NET client, we can use to communicate with the hub. SignalR also has quite a lot of events within the .NET client, and guess what we can do with those events, yep that’s right we can create IObservable
(s) streams out of them, which opens up the gates to use RX.
This article will show one area where RX excels, which is in the area of streaming APIs, where we will be using RX/SignalR.
Read the full article here: http://www.codeproject.com/Articles/851437/SignalR-plus-RX-Streaming-Data-Demo-App
