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 accomodate 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 stands 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 it’s 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 etc)
- Ability to create
IObservable
from a great many other things, such asIEnumerable
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
I have used signalR ones with a combination of a web and desktop application. It’s a great technology.
Yeah SignalR and Azure are some really great products from Microsoft.
This looks interesting. I have bookmarked the example on code project and will look at it during the week.
I also work in FX trading and have done some interesting stuff with rx for collections. Please take a look at https://github.com/RolandPheasant/DynamicData. I welcome your feedback.
Hey Roland,I checked out that stuff looks very cool, seems you certainly know your RX. Looks like a very library. Have you seen rxx.codeplex.com by any chance great stuff in there too.
Anyway hope you enjoy the article, part 2 will be out on Monday too
Thanks for the positive response. When I first unleashed dynamic data on an existing code base I was able to remove 3,000 lines of code to fix the problems associated with a single (but complex) screen. I have been hooked ever since.
I know Rxx very well. I referenced it lots especially when I was learning rx,