Condition Detection
The simplest solution pattern you will encounter in complex-event processing is threshold detection (Figure 3-5). In this pattern, a component takes an action that can be observed and results in a technical event. The condition detector is listening for this event, whose arrival serves as the trigger for analysis. The analysis compares a value conveyed by the event to a threshold value and, if the event value exceeds the threshold value, generates a business event announcing this condition. Completing the pattern, another component is listening for these announcements and taking appropriate actions.
Figure 3-5: Threshold Detection Pattern
In using this pattern the location of the threshold value must be considered. One option is to permanently fix the threshold value in the analysis logic. Another option is to make it a piece of contextual information that is looked up by the condition detector, either when it starts or each time an event is analyzed. Yet another option is to use infrastructure that makes it possible to change the value at runtime. TIBCO BusinessEvents® rule templates provide this capability, as described in Chapter 10.
The more general form of this pattern is the Condition Detection pattern (Figure 3-6). In this pattern the detected condition is defined by a number of values that define the boundaries of the condition being recognized. The information considered in the analysis is generally a combination of event and contextual data. If the condition is detected, then a business event is generated announcing the existence of the condition.
Figure 3-6: Condition Detection Pattern
When using this pattern the sources of the parameters defining the boundary conditions and the contextual data required to detect the condition must be considered, along with the possible need to change some of these values at runtime. The design effort required to provide access to information originating in other systems and make it efficiently available is often a major part of a CEP project.
In the Condition Detection pattern, the reference data that is used is not modified by the processing of events: It does not reflect prior history. The only state information being used is that conveyed by the triggering event. This makes the condition detector stateless, and therefore easy to scale and make highly available.