I get tired of showing Microsoft StreamInsight demos where my (complex) events get emitted to a console. So, as part of a recent demonstration, I built a simple Windows Form dashboard that receives events and uses the built-in Windows Form Charting Controls to display the results. In this post, I’ll show you the full solution that I built and provide a link to the download package so that you can run the whole thing yourself.
If you’re not familiar with Microsoft StreamInsight, here’s a quick recap. StreamInsight is a complex event processing engine that can receive high volumes of data via adapters and pass it through LINQ-authored queries. The result is real-time intelligence about the pattern of events found in the engine. You can read more about it on the Microsoft MSDN page for StreamInsight, my own blog posts on it, or pick up a book by a set of good-looking authors.
Assuming you have StreamInsight 1.1 installed (download here) you can execute my solution, which has these Visual Studio projects:
The first project, DataPublisher is my custom StreamInsight adapter that sends “call center” events to the StreamInsight engine.
The CallCenterAdapterPoint.cs class is my actual input adapter that leverages the FakeDataSource.cs class which creates a new CallCenterRequestEventType every 500 milliseconds. The CallCenterRequestEvenType has its properties (e.g. product, call type) randomly assigned upon creation.
The next VS 2010 project that I’ll highlight is my web service adapter (which I describe in depth in this blog post).
I’m going to use this adapter to send complex events from StreamInsight to my Windows Form.
The next project is my Windows Form project, named EventReceiver.WinUI.
This Windows Form hosts a WCF service that when invoked, updates the Chart control on the main form.
I had to do some fun work with .NET delegates to successfully host a WCF and allow the service to update the chart. Seems to work ok.
The final project, and meatiest, is the StreamInsightQuery project. This project starts up an embedded StreamInsight server, and has a set of six queries that you can play with. The first five are meant to be output to the Tracer (console) adapter. These queries show how to filter events, create tumbling windows, hopping windows and running totals. If you set the one line of code here to the query you want and press F5, you can see StreamInsight in action.
//start SI query for queries #1-5 #region Tracer Adapter Query var siQuery = query4.ToQuery(myApp, "SI Query", string.Empty, typeof(TracerFactory), tracerConfig, EventShape.Point, StreamEventOrder.FullyOrdered); #endregion
Cool. If you want to try out the Windows Form chart, simply comment out the previous siQuery variable and uncomment out the one that follows.
//start SI query for query #6 #region Web Adapter Query var siQuery = query6.ToQuery(myApp, "SI Query", string.Empty, typeof(WebOutputFactory), webAdapterConfig, EventShape.Point, StreamEventOrder.FullyOrdered); #endregion
Now, you’ll want to go and manually start up the Windows Form console, click the Start Listening button, and make sure that the status of the service is Open.
We can now press F5 again within VS 2010 and start up our StreamInsight server. Instead of writing events to the Console, StreamInsight is calling the Web adapter and sending messages to the web service hosted by our Windows Form. Within a few seconds after starting the StreamInsight server, we should see our “running totals by call center type” complex events drawing on the Chart.
When you’re finished being mildly impressed, you can shut down the StreamInsight server and then Stop Listening on the Windows Form.
So that’s it. You can download the full source code for this whole demo. StreamInsight is a pretty cool technology and I hope that by making it easy to try it, I’ve motivated you to give it a whirl.
really good stuff, I seem to be running into issues with the winform app though. I get this as missing CallCenterEvent_To_EventDashboardService.xslt .. is that missing from your zip file?
Hi Steve, that XSLT file is at the root of the solution (next to the .sln file). You likely need to change the address in the StreamInsight project.
got it, working great. pretty awesome, I have been looking for something like this, to “show” how it all works, great work.
Cool. Glad you found it useful. There are a few moving parts in a StreamInsight solution, so it’s nice when you don’t have to do much to see it in action.
Also, just a note, you may want to mention this, I had to download the samples from codeplex and build two of them to get your solution to build, the OutputTracer and SimpleFileTextWriter
Thanks for letting me know.
hi Steve, While Sample do we need to compile from the codeplex to get the SimpleFileTextWriter?
I have seen that the output adapter send the request using HTTP POST. Why WCF is not used to communicate with the client application?
Hi Kodjo, I was aiming for the lowest common denominator. I didn’t want to assume what the recipient service might look like.
Hi,
Great article and technology, thanks.
I’m more on the database technology stack rather than the visual studio/.NET side, so having a few issues getting this running, wondering if you can assist?
I too had to download the OutputTracer and SimpleFileTextWriter, all good!
But I get StreamInsight.Samples.Adapters.OutputTracer; “the type or namespace ‘StreamInsight’ could not be found”, i tried referencing it, but it doesnt show up! I registered the two adapters above using regasm.
Any help would be much appreciated…..
Thanks
Hi Scott,
Have you installed StreamInsight 1.1 itself? If you look at the path where it’s looking for the SI dlls, are there assemblies there?
Hi Richard,
es installed StreamInsight 1.1 (even went through the repair too, to make sure all ok)
When you say SI dlls, do you mean in C:\Program Files (x86)\Microsoft StreamInsight 1.1\Bin?
The StreamInsight.Samples.Adapters.OutputTracer.dll and StreamInsight.Samples.Adapters.SimpleTextFileWriter.dll werent so copied them in there, still no joy!
Cheers…
Scott,
Have you put the adapter assemblies into the GAC?
i installed streaminsight 1.1, don’t see any StreamInsight.Samples.Adapters.OutputTracer.dll anywhere (neither in the bin folder of streaminsight nor in the Package_StreamInsightSolution… please advise
update
ok, so i only found StreamInsight.Samples.OutputAdapters.Tracer, bu tit doesn’t contain a declaration for TracerKind..
Hmm. I know there have been a couple versions of this sample, and that Tracer stuff had changed. Are you able to run my sample?
Thanks,Really good example.
Hello, Stgeve, I have got installed the StreamInsight 1.2 however when I am running the project running into the issue such as
Error 1 The type or namespace name ‘Adapters’ does not exist in the namespace ‘StreamInsight.Samples’ (are you missing an assembly reference?) C:\Users\Downloads\Package_StreamInsightSolution_v1\Package_StreamInsightSolution\StreamInsightQuery\Program.cs 8 29 StreamInsightQuery
May be the package is missing one of the class?
Hi Richard, As you mentioned, the latest revision must be missing Adapters class which is causing the compilation errors.. Would it be possible to share? I am excited to see your working solution. Thanks!
Might be missing following dll – > StreamInsight.Samples.Adapters.OutputTracer.dll
Hey Ken, the latest Codeplex download for StreamInsight samples has the adapters in there. It may be in a different folder, and thus you’ll have to update my project to point to it, but it should be there.
Richard, I am sorry to say but thelatest codeplex sample does not work either.. May be the adapater file is missing in the upload.. Would you try and see if it really works?
Richard, I got it working.. Thanks!
Cannot get the example on codeplex to work either – any insight on where to find the StreamInsight.Samples.Adapters.OutputTracer.dll
Hi Al, do you not see it in this download (http://streaminsight.codeplex.com/releases/view/46435)? I see it in the Adapters folder …