Overview of the Rule Engine Framework

Most rule collections in AwareIM are un-ordered, such as rule collections attached to business objects and notifications as well as processes that have the “Maintain rule order” flag turned off. From the name of the rule collection it is clear that the order of rules in the collection does not matter. So how does the rule engine in AwareIM decide which rules to evaluate first, second and so on?

The answer is that when the rule engine starts evaluating an un-ordered rule collection it evaluates all rules of the collection at once. Actions for those rules for which conditions have been met are stored in a separate container called the agenda. The fact that there are actions on the agenda does not mean that all these actions are immediately executed – the actions are waiting until they are taken off the agenda and are executed. Actions are stored on the agenda in blocks. Action block corresponds to exactly one rule that triggers the actions of the block in the first place. Usually an action block contains just one action, however, if a rule triggers several actions the block contains several actions.

So what happens after all rules have been evaluated and placed on the agenda? The first action block is taken off the agenda and is executed. Which action block is first? The answer to this question is undefined. It is impossible to predict which action block will be executed first - the action block is taken off the agenda at random1).

What happens next? The actions of the first block randomly taken off the agenda are executed. What happens during execution of such actions is described in Action Execution. The only difference is that if the un-ordered rule collection represents rules attached to a business object and the actions modify some attribute of the same business object, then the entire collection of rules does not get re-executed again, since it is already being executed.

After the first action block has finished execution the rule engine starts to re-evaluate conditions of the rules, since the actions could have changed the state of the system (represented by values of attributes of business objects that are in the rule engine terminology called facts). Note that only those rules that depend on the facts changed by the action(s) are re-evaluated. The agenda is reviewed as well – those action blocks that represent rules with the conditions that no longer hold are removed from the agenda and the new action blocks representing rules for which the conditions hold are placed on the agenda.

After the agenda has been re-structured another action block is randomly taken off the agenda and executed. The cycle is repeated until there are no more action blocks on the agenda.

This algorithm can be summarized by the following flowchart:


1)
In fact the order is random only for action blocks that have equal priority – see priorities later in this section. In the current discussion we assume for simplicity that the order is completely random.
  • Last modified: 2025/06/12 02:09