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
- Tcpip address
- An arbitrary string that described the real time event type, for example "ClientDeal", "ExchangeFund" etc etc
- 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.
- 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 a
MessageQueue. 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.
- 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
- We could make the WCF service use callbacks to the subscribers to push notifications back to the subscribers in real time
- 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
And here is a screen shot of the working demo code
If you want to know more, you can read all about it using this article link :