As facts are asserted into the Working Memory those facts are matched against the conditions in rules, when all the conditions for a rule are matched for a given set of facts the rule along with a reference to those facts is placed onto a list of rules that could potentially fire; this list is managed and its order prioritised by the Agenda.
Activations
The Agenda maintains a List of Activations to be fired and also a List of Activations scheduled (Temporal Rules) to be fired, dictated by the duration setting of that rule.
Activations are Rules activated to fire for a given Tuple, where the Tuple contains the set of matched Facts.

Conflict Resolution
The Agenda List can contain more than one Activation, as at any time there can be one or more matching rules (or more than one matching tuple for even a single rule), as its really a list of Rules referencing Tuples, this order is maintained by the specified Conflict Resolution strategy.
Events
It is possible to monitor the activities of the Agenda via the Event Model where you can listen for the following events:
ActivationCreatedEvent ActivationCancelledEvent ActivationFiredEvent
Clear Agenda
At any time it is possible to clear the Agenda via the KnowledgeHelper instance and the clearAgenda( ) method in a consequence.
drools.clearAgenda( )
An ActivationCancelledEvent is fired for each Activation on the Agenda after it is removed.
No Loop
During the evaluation of a Rule's Consequence, if facts are modified which create a match for the current activated rule recursion may happen, potentially an infite recursion:
<rule name="example rule"> <parameter identifier="s"> <java:class>State</java:class> </parameter> <java:condition>s.getState() == true</java:condition> <java:consequence> s.setState(true); drools.modifyObject(s); </java:consequence> </rule>
To stop the current rule from being able to place itself back onto the Agenda use the no-loop attribute for a rule:
<rule name="example rule" no-loop="true">
Agenda Filter
You can gain more control over the Activations being fired on the Agenda by specifying an AgendaFilter instance as a parameter to fireAllRules. This allows you to use filters to control whether a rule activated on the Agenda gets fired

AgendaFilter filter = new AgendaFilter() { boolean accept(Activation activation) { if (activation.getRule().getName().equals("test rule") { return false; } return true; } } workingMemory.fireAllRules( filter );
You can specify more than one AgendaFilter by creating a Composite AgendaFilter. To Help with AgendaFilters we have provided several helper class implementations:
- org.drools.spi.RuleNameEndsWithAgendaFilter
- org.drools.spi.RuleNameEqualsAgendaFilter
- org.drools.spi.RuleNameStartsWithAgendaFilter
workingMemory.fireAllRules( new RuleNameEqualsAgendaFilter( "cheese" ) );


