I've been working with StreamInsight for a few weeks now and generally have it doing what I want it to do with one exception. I can't get multiple queries to run in the same process. E.g., given that eventStream is IQStreamable<eventClass>:
var query1 = from e in eventStream
where e.EventCode == "33"
select e;
var query2 = from e in eventStream
where e.EventCode == "1"
select e;
var query1Observable = from e in query1.ToPointObservable()
where e.EventKind == EventKind.Insert
select e.Payload.EventCode + ": " + e.Payload.EventDescription;
var query2Observable = from e in query2.ToPointObservable()
where e.EventKind == EventKind.Insert
select e.Payload.EventCode + ": " + e.Payload.EventDescription;
var query1Observer = myApp.DefineObserver(() => Observer.Create<string>(Console.WriteLine));
var query2Observer = myApp.DefineObserver(() => Observer.Create<string>(Console.WriteLine));
var binding = query1Observable.Bind(query1Observer).With(query2Observable.Bind(query2Observer));
using (binding.Run())
{
System.Console.WriteLine("Press enter to stop at any time.");
System.Console.ReadLine();
}
When this runs only about half of query1's events are sent to query1Observer and only about half of query2's events are sent to query2Observer. The others just disappear. If I just make my binding
query1Observable.Bind(query1Observer)
then all of the query's results are notified to the observer - but only for query1 of course. How do I run 2 queries, notifying different observers in the same process?
Have you run a trace to see what's going on? There's nothing that immediately strikes me as incorrect about your queries and it should work without issue. However, keep in mind that Console.WriteLine is static, single threaded and not the most accurate way to really "see" all events that are happening. It may well be that the events are sent but are being dropped by the observer because of locks.