Different Terms used in Drools
- 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: - 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 - 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 theKnowledgeBase
. 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: - 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 - Agenda : It’s a logical concept. The agenda is the logical place where rules are waiting to be fired.
- Activations : The then part of the rule.
Activations
are placed in the agenda where the appropriate rule is fired.
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.
No comments:
Post a Comment