Drools

13,485
-1

Published on

Overview of business rules engine with specific details on JBoss's Drools.

Published in: Technology, Education

Drools

  1. 1. An Introduction to Business Rules with JBoss Drools John Paulett October 12, 2009
  2. 2. Goals Introduction to “business rules” High level overview of JBoss Drools Discussion of benefits and shortcomings 10/12/2009 2
  3. 3. Business Rules 10/12/2009 3
  4. 4. Problem Domain Basic problem: how to model “business logic” In this context: “business logic” ≠ code between UI and DB “business logic” = policies of the business 10/12/2009 4
  5. 5. Business Logic Examples Rate calculations at insurance company ● Depends on laws, age, sex, location, previous history, desired coverage, etc. Critical lab values at hospital ● Depends on age, previous values, other lab tests, diagnose, mandates, etc. 10/12/2009 5
  6. 6. Business Rule Engine Type of Expert System Two types of rules: ● “Production (or Inference) Rules” – If x, then y – Often stateless ● “Reaction Rules” (Complex Event Processing) – Wait for set of events – Stateful 10/12/2009 6
  7. 7. Forward Chaining 1) Iterate through antecedents (if …) 2) Each time an antecedent is matched, add knowledge of consequent (then …) 3) Go to #1, until goal reached 10/12/2009 7
  8. 8. Rete Algorithm Naïve forward chaining does not scale well as number of rules increases Efficient implementation using directed acyclic graph representation of rules Higher memory consumption for increased speed 10/12/2009 8
  9. 9. JBoss Drools 10/12/2009 9
  10. 10. JBoss Drools Suite Guvnor – Business Rule Management System Expert – Production Rules Flow – Workflow Fusion – Complex Event Processing 10/12/2009 10
  11. 11. Drools Expert Core Drools product Forward chaining rules with Rete Eclipse authoring plugin 10/12/2009 11
  12. 12. Ways to Write Rules Technical Rule Language Custom Domain Specific Languages Guided Editor Decision Table 10/12/2009 12
  13. 13. Technical Rule Language rule "Hello World" when m : Message( status == Message.HELLO, myMessage : message ) then System.out.println( myMessage ); m.setMessage( "Goodbye cruel world" ); m.setStatus( Message.GOODBYE ); update( m ); end 10/12/2009 13
  14. 14. Custom DSLs Map “natural language” into Technical Rule Language 10/12/2009 14
  15. 15. Guided Editor From http://www.jboss.org/drools/drools-expert.html 10/12/2009 15
  16. 16. Decision Table Excel XLS based 10/12/2009 16
  17. 17. Drools Guvnor BRMS – Business Rule Management System Centralized knowledgebase Web-based rule authoring Versioning of rules 10/12/2009 17
  18. 18. Drools Guvnor Manage rules through web console From http://www.jboss.org/drools/drools-guvnor.html 10/12/2009 18
  19. 19. Drools Guvnor Edit rules through web console From http://www.jboss.org/drools/drools-guvnor.html 10/12/2009 19
  20. 20. Drools Flow Workflow management From http://www.jboss.org/drools/drools-guvnor.html 10/12/2009 20
  21. 21. Drools Fusion Extension to Drools Expert for temporal reasoning Detects relevant patterns in “cloud or stream of events” 10/12/2009 21
  22. 22. Discussion 10/12/2009 22
  23. 23. When To Use a Rules Engine Large set of rules, with complex branching Rules likely to change over time, likely out of sync with code changes Involve “business users” in creation & maintenance of rules 10/12/2009 23
  24. 24. Benefits Separates “business logic” from application code “Hot” changes of rules (no recompile) Improved performance for large rule sets Communicates rules more clearly than Java code 10/12/2009 24
  25. 25. Downsides New tool ● Learning curve ● Extra point of failure Overhead ● Not practical for small rule sets 10/12/2009 25
  26. 26. Alternatives Java Rule Engine API - JSR 94 Closed Source: ● IBM's ILOG JRules, Fair Isaac's Blaze Advisor Open Source: ● Jess, OpenRules, Zilonis, take 10/12/2009 26
  27. 27. References http://www.jboss.org/drools/ http://java.sun.com/developer/technicalArticles/J2SE/JavaRule.html http://java.sys-con.com/node/45082 http://herzberg.ca.sandia.gov/guidelines.shtml 10/12/2009 27
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×