Sending StreamInsight Events to a Windows Form Dashboard (Code Included)

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:

2011.4.18si01

The first project, DataPublisher is my custom StreamInsight adapter that sends “call center” events to the StreamInsight engine.

2011.4.18si02

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).

2011.4.18si03

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.

2011.4.18si04

This Windows Form hosts a WCF service that when invoked, updates the Chart control on the main form.

2011.4.18si05

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

2011.4.18si06

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.

2011.4.18si07

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.

2011.4.18si08

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.



Categories: StreamInsight

25 replies

  1. 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?

  2. 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

  3. I have seen that the output adapter send the request using HTTP POST. Why WCF is not used to communicate with the client application?

  4. 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?

  5. 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

  6. update
    ok, so i only found StreamInsight.Samples.OutputAdapters.Tracer, bu tit doesn’t contain a declaration for TracerKind..

  7. Thanks,Really good example.

  8. 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?

  9. 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

  10. 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?

  11. Cannot get the example on codeplex to work either – any insight on where to find the StreamInsight.Samples.Adapters.OutputTracer.dll

Trackbacks

  1. Distributed Weekly 99 — Scott Banwart's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: