Try OpenEdge Now
skip to main content
BPM Events User's Guide
The rule language : Controlling rule execution : Canceling multiple evaluations of a rule
 

Canceling multiple evaluations of a rule

You may trigger a rule several times on a single event, if it involves event correlation.
Consider a situation where we try to detect at least one high-priority purchase order currently processing on server S, as soon as the load of server S reaches a critical threshold. If yes, then we take some action, that is, decrease the load of the server. The rule that takes action requires correlating two types of events: (1) server overload notice, (2) open purchase order of high priority. The rule is:
rule Server_load_reduce
activated by
EVT_A of request::PurchaseOrder,
EVT_B of ServerStatus::load
try SINGLE_CASE
if (EVT_A.priority = "High") and
(toInt(EVT_B.load) > 10) and
(EVT_A.server = EVT_B.server)
then {
perform(<some action>);
}
When an event triggers the rule on EVT_B (server load over 10), several purchase orders may be currently open on this server, each of which has logged an event that satisfies the condition on EVT_A. In that case, the normal behavior of a rule is to execute its action (perform) as many times as there are event pairs (EVT_A, EVT_B) that satisfy the rule condition (Event pairs may share the same event.). However, we want the rule to execute only once, no matter how many orders are in, provided there is at least one for this server. The clause try SINGLE_CASE automatically cancels the evaluation of all remaining pairs as soon as one pair (EVT_A, EVT_B) triggers the rule successfully, thus enforcing a single action evaluation.