Using Observable and Enumerable Event Sources and Event Sinks (StreamInsight)

StreamInsight supports event sources and event sinks that implement the IObservable and IEnumerable interfaces. These interfaces are the dominant general-purpose contracts in the .NET Framework for pulling (IEnumerable) and pushing (IObservable) data among the components of an application.

While the IEnumerable and IEnumerator interfaces are already familiar to .NET developers, the IObservable and IObserver interfaces were introduced more recently in the .NET Framework 4. The IObservable development model is based on the observable/observer design pattern. In this design pattern:

  • An observer is any object that wishes to be notified when the state of another object changes.

  • An observable is a push-based sequence, in which another object may register an interest.

In a StreamInsight application, the observable is the event source. The query acts as an observer of this source, and presents its result as an observable to the event sink, which is in turn an observer of the query as the source. For more information, see Exploring the Observer Design Pattern on MSDN.

The tasks for the application developer to enable this development model are minimal:

  1. Provide a class that implements the IObservable or IEnumerable interface as the event producer.

  2. Provide a class that implements the IObserver interface, or a class that consumes an IEnumerable, as the event consumer.

  3. Bind these objects to queries.

This development model does not require a major learning or programming investment to define the temporal properties of the events, or awareness of the underlying state transitions of the core adapter model. Here are some scenarios in which this development model is appropriate:

  1. Historical queries. Financial analyst Alice identifies patterns in historical market data by executing temporal queries over large data sets. In this case, the input stream has a definite end – after the last data element is processed, the query should end.

  2. Ad hoc queries over live sources. Server administrator Bob suspects a denial of service attack. He identifies the source of the attack through an iterative series of ad hoc queries over the streams of network data that he is monitoring.

  3. Embedded in custom applications. User interface developer Charlie designs analyzes patterns of mouse gestures by using temporal queries over Windows events. StreamInsight is embedded in the custom application.

In each of these cases, the query exists only so long as the client application cares to listen to the results.

In This Section

This section contains the following topics:

Programming considerations for observable and enumerable sources and sinks

Observable and enumerable sources and sinks are supported only in embedded solutions

Observable or enumerable event sources and sinks are supported only in the hosted deployment model, where the StreamInsight server is embedded in the application. You cannot use observable or enumerable event sources and sinks with the standalone or remote server deployment model. For more information on deployment models, see StreamInsight Server Deployment Models.

API features support the temporal requirements of StreamInsight

The API permits full fidelity with StreamInsight’s temporal model, including the enqueuing of CTI events.

  • On observable and enumerable inputs:

    • The To[Point|Interval|Edge]Stream methods wrap the input data as StreamInsight events and specify the temporal characteristics of the source data.

    • A helper method and properties on the AdvanceTimeSettings class help the developer to specify the frequency at which CTI events are enqueued, thereby determining the liveliness of the input data.

  • On observable and enumerable outputs, the developer can choose whether or not to incorporate time information in the form of point, interval or edge events through the To[Point|Interval|Edge]Observable and To[Point|Interval|Edge]Enumerable methods.

Observable support depends on the Microsoft .NET Framework 4

If your application uses event sources or sinks that implement the IObservable or IObserver interfaces:

  • The application must reference the assembly Microsoft.ComplexEventProcessing.Observable.dll.

  • The application must target .NET Framework 4 (not the .NET Framework 4 Client Profile).