Try OpenEdge Now
skip to main content
BPM Events User's Guide
The rule language : Operational semantics of rules : Event correlation
 

Event correlation

By correlating events, rules can detect event patterns spanning long periods of time. Once a combination of events is found that satisfies the event pattern condition, the rule has succeeded in correlating these events.

Example

For example, in order to measure the completion time in business hours of a BP Server process (called here "HelpDesk") we correlate two events: the activation (PI_ACTIVATED) event and the completion (PI_COMPLETED) event of this process instance. The following rule calculates a completion time as the difference between the time stamps of these two events. The resulting time is used to update a value averaging all completion times for the HelpDesk process.
    rule record_process_time
    activated by
    evt1 of BP Server::PI_ACTIVATED{PROCESSTEMPLATENAME : "HelpDesk"},
    evt2 of BP Server::PI_COMPLETED{PROCESSTEMPLATENAME : "HelpDesk"}
    correlated with INDEX
    then {
        val report = HelpDeskReport[1][1];
        report.avg_time ::=
        avg(duration(B_HOUR, evt1.date, evt2.date), report.count++, 1);
    }
{HelpDeskReport := new infopad <cell{avg_time:int}>[1][1]("HelpDeskReport");
}
In the sample above, the mode correlated with INDEX guarantees that every combination of events (evt1 and evt2) is correlated based on the default association criterion, which is the process instance ID associated with each event. In other words, these events are generated by the same process instance. Without this keyword, we must explicitly write the correlation condition in the if clause:
(evt1.PROCESSINSTANCEID = evt2.PROCESSINSTANCEID)
Note: Progress Software Corporation strongly recommend using correlated with INDEX whenever a rule correlates events of type BP Server that generate from the same process instance. If not, the performance of the rule degrades in proportion to the number of events present in cache.
Do not use correlated with INDEX if an index was not defined for an event type. To define an index for your own event type of an XML message, implement the public function get_group_id(). See Eventcaching and indexing for more information.
* The triggering event and the correlating event