Information Technology Reference
In-Depth Information
a certain time after the second event, and if it has a second parameter, this indicates that
the second event happened within a range after the first event. The following code is an
example of a rule condition using the after operator:
when
p1: ProcessEvent($processId1 : processId)
p2: ProcessEvent(this after[3m] p1, processId ==
$processId1)
...
In the preceding example, we are first detecting an event of type ProcessEvent and
then trying to find another one that has the same processId attribute and happened at
least 3 minutes after the first one. In ProcessCEPTest , you can see an example of a
code running this structure in the testAfterRule test method.
Sliding windows
Another important concept behind Drools Fusion CEP functionalities are sliding win-
dows. They define an interval of interest in which we want to start filtering or grouping
our events. It comes in two flavors, windows of length and windows of time. The best
way to explain them both is with a simple example:
HeartBeatEvent() over window:time(15s)
The preceding code should be read as follows: get all HeartBeatEvents that have
happened in the last 15 seconds. Another example could be:
TemperatureEvent() over window:length(5)
The preceding code should be read as follows: get the last five TemperatureEvents
that have been added to the rule runtime memory.
Drools Fusion in action
Now that we have seen all the components needed to define temporal reasoning in our
business rules, we need to start considering the different configurations required to make
our CEP business rules run smoothly, as well as how to integrate them with our business
processes. All considerations needed to run simple business rules together with business
processes apply to Drools Fusion (that is, having the RuleAwarePro-
cessEventLister listener and the custom listener AgendaEventListener to fire
Search WWH ::




Custom Search