Share via


Implicit Server Development Model

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The implicit server development model provides an easy-to-use environment that hides much of the complexity that is associated with the explicit server development model. It hides this complexity by letting the CEP server act as the implicit host. Through which it creates and registers most of the objects that are required to transform and process events coming into and going out of the CEP server. This allows time for a developer to focus his or her efforts on developing the query logic that is needed to process and analyze the events within the CEP server. The server object itself is "anonymous" and cannot be accessed directly through the object model.

The following use cases are supported by the implicit server development model:

  • Embedding the CEP server in an application in which only queries or query templates are immediately bound and run.
  • Accessing a server object is not required to add or remove specific metadata entities or to retrieve diagnostic information.
  • Serving as a test environment for query developers.

Key Characteristics of the Implicit Server Development Model

The key characteristics of the implicit server development model are as follows:

  • The CEP server is created implicitly for each query. The query is automatically hosted in the hosting environment at run time.
  • The query is stored in memory and is not stored on disk or other stable storage device.
  • A developer does not have to explicitly create the server, query template, and other application objects. As the implicit host, the CEP server performs the following tasks:
    • Creates the event type. The CEP server uses reflection to extract the event type information from the CLR type and registers the type.
    • Registers the input and output adapters based on the query binding information that is provided by a developer. The adapters are defined by the adapter factory and configuration information. By using the specified configuration, the adapter factory produces an instance of the input or output adapter. The configuration information must be XML serializable.
    • Registers the query template and query.
    • Manages the lifetime of the CEP server. The server is started when the query is started and is disposed when the query is disposed.
  • A developer must provide input adapter and output adapter binding information. This can be as simple as supplying an Observer object for the output and an Observable object for the input, or as complex as writing fully-controlled input and output adapters. However, the developer does not have to explicitly specify a binding between the adapters and the query.
  • A developer must specify the query logic and the binding information.

Examples

Creating a simple application by using the implicit server development model

The following example creates a simple application by using the implicit server development model. The input and an output adapter are directly bound to a query template before the query is started. The input stream is defined by using the input adapter factory so that the CEP server can create an instance of the input adapter at run time. Similarly, a stream consumer is defined by using an output adapter factory. The query object is directly created from the LINQ query template by using the stream consumer. An explicit query template object does have to be registered into the CEP server, and a query binder does not have to be specified.

void ImplicitServerQuery1()
{
    // Configure input and output adapter.
    var inputConf = new TextFileInputConfig("MyData.csv");
    var outputConf = new TextFileOutputConfig("Result.csv");

    // Define a stream directly from the input adapter factory.
    var inputStream = CepStream<PayloadType>.Create("inputStream",
                                                    typeof(TextFileInputFactory),
                                                    inputConf,
                                                    EventShape.Point);

    // Define the query logic.
    CepStream<PayloadType> filter = from e in inputStream
                                    where e.value > 10
                                    select e;

    // Create the query from the LINQ statement and submit it into the consumer.
    Query query = filter.ToQuery(typeof(TextFileOutputFactory),
                                 outputConf,
                                 EventShape.Interval,
                                 StreamEventOrder.FullyOrdered);

    query.Start();

    // Perform other work in this thread as needed. For example, wait for the output adapter to
    // signal its completion.

    query.Stop();
}

See Also

Concepts

Development Scenarios
Explicit Server Development Model