Show TOC

Background documentationFiring Queue Locate this document in the navigation structure

 

Firing Queue, at any given instance, represents a collection of all the actions of all the satisfied rules that are to be fired by the Engine.

When a rule is satisfied, the Engine creates an entity which represents all the actions for this rule. This entity is then added to the Firing Queue at the appropriate place depending on the rule's priority. The Engine then retrieves each entity from the Firing Queue and fires the actions in that entry.

The Firing Queue is a buffer which maintains:

  • Satisfied rules in the order of the priority. This means that the first rule in the Firing Queue is the rule with the highest priority

  • In case there are rules with the same priority, they will be in the order in which they were added to the Firing Queue

Once all objects are examined, the Engine proceeds to fire rules in the Firing Queue. The actions in each rule are performed one by one. The consequences of actions could be:

  • Further examination of objects: This is usually true in the case of action types Assert or Re-evaluate.

  • The size of Firing Queue is dynamic and may vary during the duration of the invokeRuleset method. Typically, rules are added to the Firing Queue, but rules may be removed. The following are situations when rules may be removed from the Firing Queue

    • An object is retracted using the Retract action type: If Rule A was satisfied by a business object and this object is retracted by the action of Rule B, then Rule A is removed from the Firing Queue

    • The ReEvaluate Conditions for Changes After Executing Actions option is enabled for a ruleset: If the outcome of the current evaluation of a rule validated to false and the rule is still in the Firing Queue, that rule is removed from the Firing Queue

    • A variable definitions changed by the Assign action type: If a rule which was satisfied earlier for the variable definition is no longer satisfied, then that rule is removed from the Firing Queue

    • An object is reevaluated using the Re-evaluate action type: The Re-evaluate action type causes unfired rules to be removed from the Firing Queue irrespective of whether they are still satisfied or not. If they are satisfied after the re-evaluate, it is added to the Firing Queue again.

Outcome of Previous Examination

Outcome of Current Examination

How Rules Engine Handles This

True

True

No change.

True

False

Remove the rule from the Firing Queue.

False

True

Add the rule to the Firing Queue.

False

False

No change.

Clarifications
  • If the actions of a rule are already fired, their results can not be undone. Removing a rule from the Firing Queue implies removing the actions for that rule only if they have not already been fired.

  • Rules are placed in the order of their priority in the Firing Queue.