Sunday, September 2, 2018

Drools



What is Drools ?


  • Drools is a Business Logic Integration Platform(BLiP).  It is written in Java.  It is an open source project that is backed by JBoss and Red Hat, Inc.,

  • It extends and implements the Rete Pattern matching algorithm.

  • In layman's terms, Drools is a collection of tools that allow us to separate and reason over logic and data found within business processes.


What is Rule ?

Rules are pieces of knowledge often expressed as "When some conditions occur,  then do some tasks."

The most important part of a Rule is its when part.  If the when part is satisfied, the then part is triggered.


Ex syntax  :

    rule <rule_name>
        <attribute>  <value>
        when

              <conditions>
        then
              <actions>

end


Rule Syntax 

Conditions in Rules :

->  A rule can contain many conditions and patterns such as :
->  Account (balance==200)  Customer (name =="Vivek")
->  The above conditions check if the Account balance is 200 or the Customer name is "Dev"

Variables in Rules :

A variable name in Drools starts with a Dollar($) symbol.
$account : Account()
$account is the variable for Account() class Droos can work with all the native Java types and even Enum.



Decision Table

Drools supports managing rules in a Spreadsheet format.  Formats supported are Excel, and CSV.
The key point to keep in mind is that in a decision table, each row is a rule, and each column in that row is either a condition or action for that rule.

The spreadsheet looks for the "Rule Table" keyword  to indicate the start of a rule table(both the starting row and column).

The RuleSet Keyword indicates the name to be used in the "rule package" that all the rules will come under.

The keywords CONDITION and ACTION indicate that the data in the columns below are for either the LHS or the RHS parts of a rule.






Setup  :



http://download.jboss.org/drools/release/5.3.0.Final/ 

No comments:

Post a Comment

Hyderabad Trip - Best Places to visit

 Best Places to Visit  in Hyderabad 1.        1. Golconda Fort Maps Link :   https://www.google.com/maps/dir/Aparna+Serene+Park,+Masj...