Drools :: Rule Keywords and Attributes


insert keyword

new IsLowCostOrder($i) is the data available to the working memory using the insert keyword.



modify and update keywords

After the modification: setMale(true), the engine will re-evaluate all rules for Person object.

In Drools when you invoke update() or modify() on a given object it will trigger a re-evaluation of all patterns of the matching object type in the knowledge base.


not keyword

An alarm is removed and all sprinklers have been turned off. The rule uses the not keyword to make sure that at the moment of firing the rules, we have at least an Alarm or Springkler object. If we don’t, it will print a warning.

delete and retract keywords

The delete and retract keyword remove the objects from the working memory. The retract keyword is deprecated. Their syntax is equivalent.



BOOLEAN Default value: false.
When a rule’s consequence modifies a fact, it may cause the rule to activate again, causing an infinite loop. Setting no-loop to true will skip the creation of another activation for the rule with the current set of facts.


BOOLEAN Default value: false.
Whenever a ruleflow-group becomes active or an agenda-group receives the focus, any rule within that group that has lock-on-active set to true will not be activated any more. Regardless of the origin of the update, the activation of a matching rule is discarded. This is a stronger version of no-loop because the change is not only caused by the rule itself. It is ideal for calculation rules where you have a number of rules that modify a fact, and you do not want any rule re-matching and firing again. Only when the ruleflow-group is no longer active or the agendagroup loses the focus, those rules with lock-on-active set to true become eligible again for their activations to be placed onto the agenda.


INTEGER Default value: 0.
Each rule has an integer salience attribute which defaults to zero and can be negative or positive. Salience is a form of priority where rules with higher salience values are given higher priority when ordered in the activation queue.

Drools also supports dynamic salience where you can use an expression involving bound variables like the following:


Ruleflow is a feature that lets you exercise control over the firing of rules. Rules that are
assembled by the same ruleflow-group identifier fire only when their group is active. This
attribute has been merged with agenda-group and the behaviours are basically the same.


STRING Default value: MAIN.
Agenda groups enable you to partition the agenda, which provides more execution control. Only
rules in the agenda group that have acquired the focus are allowed to fire. This attribute has been
merged with ruleflow-group and the behaviours are basically the same.


BOOLEAN Default value: false.
When a rule is activated where the auto-focus value is true and the rule’s agenda group does
not have focus yet, it is automatically given focus, allowing the rule to potentially fire.


Rules that belong to the same activation-group identified by this attribute’s String value, will
only fire exclusively. More precisely, the first rule in an activation-group to fire will cancel all
pending activations of all rules in the group, for example stop them from firing.


STRING Default value: specified by the package.
Java and MVEL are the possible values of the dialect attribute. This attribute specifies the
language to be used for any code expressions in the LHS or the RHS code block. While the dialect
can be specified at the package level, this attribute allows the package definition to be overridden
for a rule.


A rule can only activate if the current date and time is after the date-effective attribute. Note
that STRING is a date and time definition. An example date-effective attribute is displayed


A rule cannot activate if the current date and time is after the date-expires attribute. Note that
STRING is a date and time definition. An example date-expires attribute is displayed below:


If a rule is still true, the duration attribute will dictate that the rule will fire after a specified


Leave a Reply