Search code examples
c#.netstreaminsight

StreamInsight InputAdapter shares events among mutiple queries


I am observing a very weird processing of the events in my StreamInsight application. There is one InputAdapter which devides the Stream into TumblingWindows. Then I have multiple queries running at the same time. They should use all the same TumblingWindows from the same Stream. I used this code to define the windows:

var atgs = new AdvanceTimeGenerationSettings(config.Input.EventCount, 
                    TimeSpan.FromSeconds(config.Input.Delay), true);
                var ats = new AdvanceTimeSettings(atgs, null, AdvanceTimePolicy.Adjust);

                var dstream = CepStream<Dataclass>.Create("Data Input Stream", typeof (InAdapterFactory),
                    config.Input, EventShape.Point, ats);

 var unfilteredtumbling = dstream.TumblingWindow(TimeSpan.FromSeconds(processinginterval),HoppingWindowOutputPolicy.ClipToWindowEnd);

Then I execute two different queries from this stream. Using this code:

var count = from row in unfilteredtumbling 
                         select new
                         {
                             value= row.Count(),
                             qind = 10,
                             stat = "Calculated Count"

                         };
var count2 = from row in unfilteredtumbling 
                         select new
                         {
                             value= row.Count()*2,
                             qind = 10,
                             stat = "Calculated Count2"
                         };

Bind each to their own OutputAdapter like this:

Query querycount = count.ToQuery(myApplication, "Count Output Query", "Output Count",
                        typeof (OutputAdapterFactory), config.Output, EventShape.Point, StreamEventOrder.FullyOrdered);
Query querycount2 = count2.ToQuery(myApplication, "Count Output Query2", "Output Count2",
                        typeof (OutputAdapterFactory), config.Output, EventShape.Point, StreamEventOrder.FullyOrdered);

The following link shows the output I receive.

https://dl.dropboxusercontent.com/u/15482726/outputissue.jpg

The output I receive is unfortunately not that what I expect. Looks like every query gets its own inputadapter. And the messages are distributed to both Input Adapters. Even though dstream is only created once but the factory is called twice. But why and when? how is that possible? If I use only one Query everything works perfect.

I used the explanation from this link http://technet.microsoft.com/en-us/library/ff518536.aspx Thought it should work that way.

Any help is very welcome.

Best regards Joe


Solution

  • Take a look at this post from Mark Simms: http://blogs.msdn.com/b/appfabriccat/archive/2010/11/22/streaminsight-understanding-dynamic-query-composition.aspx.