Rules with Drools
Gaurav KohliSaket Vishal
Recognize this?
3.1732
What about this?
Akshay Kumar,32, Chandini Chowk,
Delhi, 110006
Lets talk about
Akshay Kumar
Some rules on names• First Name + Last Name• First Name + First Name + Last Name• (First Name)+ + Last Name
• First Name + First Name– Saket Vishal
Implementing these rules in Java
Demo
Problems in implementing with Java
• Frequent changes to rules(conditions)• Lack of centralization of rules– Difficult to analyse and manage
• Non technical people(Business Analysts ..) can't create/update rules
• Performance
Introducing DroolsBasically, a rule engine
Rule Engine: Platform that provides functionality to manage rules
Rule: An if else condition (Business Logic)
Rules in Drools
Demo
The Big Picture
Back to rules in DroolsDSL – Domain Specific Languages– Human readable rules
Demo
Behind Drools• RETE
Behind Drools
If your business logic is well defined/static and doesn't change often, you don't need to change rules at run-time.
If your rules are simple, self-contained, and usually spanning only a single object (for example, a check that user's age is less than 21).
If you have a memory constrained environment.
If your project is a one-shot effort and it will never be used again ormaintained over time.
When not to use Drools
ILOG (now IBM)—JRules
Fair Isaac—Blaze Advisor
Corticon's BRMS,
Haley (now Oracle) Business Rules Engine
Pegasystems—PegaRules,
Production Systems Technologies—OPSJ
CLIPS
OpenRules or Jess
Alternatives to Drools
Advanced Drools• Drools Flow – Loan approval
• Drools Fusion– Fraud detection
• Drools Guvnor– BRMS
?
References• Drools
• http://www.jboss.org/drools• Drools JBoss Rules 5.0 Developer's Guide
• RETE• http://en.wikipedia.org/wiki/Rete_algorithm
Thank You!