An overview of when to create and run dynamic queries and streams.
The ability to dynamically run or stop CCL statements and streams is useful if you have a system that is not static. For example, consider an application that monitors building security. The input events may come from door sensors, key-card readers, and smoke detectors, while the output events might include alerts to the security personnel or the fire department. Different queries are required on work days than on non-work days, and some queries need to run continuously while others should be activated or deactivated (automatically or via user intervention) based on the time of day and the day of the week.
The building security application might contain the following:
Smoke detector alerts: Monitors the smoke detectors and send an alarm to the fire department if smoke is detected. The query(s) and streams related to smoke detectors are not dynamic; they are never "turned off".
Side-door alerts: During all hours, an alert is sent to the on-site security guards if any "side doors" (any doors other than the main entrances) are opened without the use of a valid electronic badge.
Front-door alerts: During non-working hours, an alert is sent to the on-site security guards if a front door is opened without the use of a valid electronic badge. This alert is not sent during working hours.
We can model this system as shown below. There are 3 input sources, 3 queries, and 2 destinations for alerts:
Sybase CEP Studio can be used to create a project that contains the Smoke Alarm input stream, the Fire Department output stream, and query Q1. The project can then be started and left to run indefinitely.
A project can also be created to have the Side Door input stream, the Guard output stream, and query Q2 running continuously.
To have the Front Door input stream and the query Q3 run only outside of normal working hours, a separate program can be used to register (create and run) them at the appropriate times. These streams would stop running during periods when they are not needed.