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.
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:
Facts
. It can be a simple Java POJO or a complex object. Java object is synonyms to facts in DroolsKnowledge 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: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.
Drools
these are commonly referred to as knowledge definitions or knowledgeActivations
are placed in the agenda where the appropriate rule is fired.