Specifications

154 CHAPTER 8 Complex Event Processing with StreamInsight
Another task the adapter must perform is classication of an event. That is, the adapter
must specify the event kind as either INSERT or Current Time Increment (CTI). The adapter
adds events with the INSERT event kind to the stream as it receives data from the source. It
uses the CTI event kind to ignore any additional INSERT events it receives afterward that have
a start time earlier than the timestamp of the CTI event.
Query Templates
Query templates encapsulate the business logic that the CEP server instantiates as a standing
query instance to process, lter, and aggregate event streams. To dene a query template,
you rst create an event stream object. In a standalone server environment, you can create
and register a query template as an object on the CEP server for reuse.
The Event Stream Object
You can create an event stream object from an unbound stream or a user-dened input
adapter factory.
You might want to develop a query template to register on the CEP server without binding
it to an adapter. In this case, you can use the Create() method of the EventStream class to
obtain an event stream that has a dened shape, but without binding information. To do this,
you can adapt the following code:
CepStream<PayloadType> inputStream = CepStream<PayloadType>.Create("inputStream");
If you are using the implicit server development model, you can create an event stream
object from an input adapter factory and an input conguration. With this approach, you
do not need to implement an adapter, but you must specify the event shape. The following
example illustrates the syntax to use:
CEPStream<PayloadType> inputStream =
CepStream<PayloadType>.Create (streamName, typeof(AdapterFactory), myConfig,
EventShape.Point);
The QueryTemplate Object
When you use the explicit server development model for standalone server deployment,
you can create a QueryTemplate object that you can reuse in multiple bindings with differ-
ent input and output adapters. To create a QueryTemplate object, you use code similar to the
following example:
QueryTemplate myQueryTemplate = application.CreateQueryTemplate("myQueryTemplate",
outputStream);