Signup/Sign In

Different Terms used in Drools

In this tutorial we will cover some important terms used in Drools. This is good to know stuff for a beginner so that you start understanding what various terminologies are in Drools world.

  1. Rules: Rules are the heart of the Rule Engine. In rules you specify the condition and then the execution part of the condition. Below is the syntax of the rule in drools:

    Different Terms used in Drools


  2. Facts: The objects on which the rules are fired are known as Facts. It can be a simple Java POJO or a complex object. Java object is synonyms to facts in Drools

  3. Session: Knowledge Session in Drools is the core component in which rules are fired. The knowledge session holds all the rules and other resources. Knowledge Session is created from the KnowledgeBase. To trigger the rules, facts are inserted into the session and when a condition of a particular rule is met, the subsequent rule gets fired. Session is of two types:
  4. a) Stateless KnowledgeSession: A Stateless knowledge session won't track the changes in the facts while the rules are being fired. In simple words once we have inserted all the facts in the session and triggered all the rules then the rules cannot be fired on the updated facts. To draw a parallel, it would be similar like a web application where we are not tracking the session.

    b) Stateful Knowledge Session: In a Stateful knowledge session, once all the facts are inserted and rules are triggered and one rule is updating the fact and post the updation of fact another rule can also trigger as the fact is still in the session. Its similar where in a web application until the session is active all the items you add to the cart are visible.


  5. KnowledgeBase: This is an interface that manages a collection of rules, processes, and internal types. In Drools these are commonly referred to as knowledge definitions or knowledge

  6. Agenda: It's a logical concept. The agenda is the logical place where rules are waiting to be fired.

  7. Activations: The then part of the rule. Activations are placed in the agenda where the appropriate rule is fired.