Just Noticed

Hey dear reader, I just noticed that one of my articles is up for best c# articles of the month over at codeproject this month.

If you have read the article and truly think its worth a vote, maybe you could take 2 minutes to vote in monthly competiton.

Competition voting can be made here : http://www.codeproject.com/script/Surveys/VoteForm.aspx?srvid=1252

My article is this one : “Restful WCF / EF POCO / UnitOfWork / Repository / MEF : 1 of 2″

Obviously you should only vote, if you feel it deserves it.

Thanks

Streaming results to web page using MSMQ/WCF/SignalR/JQuery

Where I work is a Fx (Foreign Exchange) company and we trade Fx for clients all over the world, and the other day my boss came up to me and stated that he would like to be able to visualise where trades where they were happening in real time, but he wanted it too look cool, a kind of shiny showcase type of thing (I am sure you know what I mean). He categorically stated no grids. I was pleased.

My team mate Richard and I were tasked with this, so we thought about this and looked at what sort of information we had available, and wondered if we could make some sort of generic real time event watcher that would also produce some sparkly interface for us to show off.

We did NOT have much information to work with, we pretty much ONLY had the following

  1. Tcpip address
  2. An arbitrary string that described the real time event type, for example "ClientDeal", "ExchangeFund" etc etc
  3. The name of the client

So we thought about it a bit more, and what we came up with was something along the lines of this scenario.

  1. We could extend our logging framework (we use Log4Net), where we could create a custom MessageQueue(MSMQ) appender, which would log certain events and some extra data (such as Tcpip address) to aMessageQueue. Obviously we could not share our entire application so we have provider a test message publisher that simply writes test messages to a MessageQueue. This part should be pretty easy to figure out should you want to come up with your own stuff to generate the real time events.
  2. We could have a WCF service read these MessageQueue entries in real time. This service could take in subscribers, where each subscriber could subscribe for a single event using the event name, or multiple events, by passing an array of event names on subscription
  3. We could make the WCF service use callbacks to the subscribers to push notifications back to the subscribers in real time
  4. We could also use Google Earth to show these events (if we could obtain GeoLocation data for the event) in real time

Most of this is fairly standard stuff, the actual interesting part is pushing notifications from some server side web code back to the browser in real time. I don’t know how many of you have seen that before, but it is like what Google do when you open a Google search page and search for something that is quite populaar (say some news worthy item), and Google will actual stream live results at you straight into your open search page.

It’s very cool, and is usually accomplished using long polling or various other techniques using Ajax/Comet techniques, all of which are very hard to set up and get working (at least in our opinion).

What we ended up doing was using a rather new library called SignalR, which I have say is pretty darned cool.

Here is an overview of what we came up with

overallArch

And here is a screen shot of the working demo code

vid

If you want to know more, you can read all about it using this article link :

http://www.codeproject.com/Articles/324841/EventBroker

Enjoy