Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Rules Engine Overview Scott Ryan September 2007
Agenda <ul><ul><li>Rule Systems Overview </li></ul></ul><ul><ul><li>Rule Development Options </li></ul></ul><ul><ul><li>To...
Overview
Major Components <ul><ul><li>Working Memory/Sessions </li></ul></ul><ul><ul><ul><li>Rule Sets </li></ul></ul></ul><ul><ul>...
Working Memory <ul><ul><li>Stateful </li></ul></ul><ul><ul><li>Stateless </li></ul></ul><ul><ul><li>Can be dynamically upd...
Rule Sets <ul><ul><li>Contain groupings of Rule Packages </li></ul></ul><ul><ul><li>Are associated with a Session </li></u...
Packages <ul><ul><li>Contain sets of rules </li></ul></ul><ul><ul><li>Are serializable </li></ul></ul>
Rules <ul><ul><li>Come in various formats </li></ul></ul><ul><ul><ul><li>DRL/DSL </li></ul></ul></ul><ul><ul><ul><li>XML <...
XML Rule <!-- Check for XYZ Corp-->  <rule name=&quot;XYZCorp&quot; salience=&quot;-1&quot;> <!-- Parameters we can pass i...
DRL Rule rule  &quot;Time Zone One&quot; no-loop   true when $w : WorkItem(address.state.value  memberOf  timeZoneOneState...
Facts <ul><ul><li>Objects that Rules act upon </li></ul></ul><ul><ul><li>Follow Java Bean Rules </li></ul></ul><ul><ul><li...
Global and Non Fact Objects <ul><ul><li>Used to provide data or functions </li></ul></ul><ul><ul><li>Injected during packa...
Toolsets <ul><ul><li>Eclipse Based Development </li></ul></ul><ul><ul><li>Eclipse Based Debugging </li></ul></ul><ul><ul><...
Rule Management <ul><ul><li>File and/or classpath loading </li></ul></ul><ul><ul><li>JNDI Loading </li></ul></ul><ul><ul><...
Rule Modification <ul><ul><li>Property or Database Driven </li></ul></ul><ul><ul><li>DSL based </li></ul></ul><ul><ul><li>...
Sample Implementation <ul><ul><li>Simple Replacement of existing Business Rule Interface </li></ul></ul><ul><ul><li>Code <...
Problem Domain
Pros <ul><ul><li>Declarative Programming Model </li></ul></ul><ul><ul><ul><li>Concentrate on the what not the how </li></u...
Cons <ul><ul><li>New thought processes </li></ul></ul><ul><ul><li>Somewhat black box </li></ul></ul><ul><ul><li>Separation...
Spring Support Rule @Rule( name=&quot;Set Pump to Cooling&quot;,  documentation=&quot;If a floors temperature becomes too ...
Spring Support When @Condition  public  boolean isPumpOff(@Fact HeatPump pump)  {  return  pump.getState() == OFF;  }
Spring Support Then @Consequence  public  void consequence(HeatPump pump)  {  pump.setState(COOLING);  }
Spring Configuration <bean id=&quot;pumpRuleSet&quot; class=&quot;org.drools.spring.factory.RuleSetFactoryBean&quot;>  <pr...
Upcoming SlideShare
Loading in …5
×

Rules Engine Overview Denver Java User's Group Sept 2007

953 views

Published on

An overview of rules engines and their development and deployment

  • Be the first to comment

Rules Engine Overview Denver Java User's Group Sept 2007

  1. 1. Rules Engine Overview Scott Ryan September 2007
  2. 2. Agenda <ul><ul><li>Rule Systems Overview </li></ul></ul><ul><ul><li>Rule Development Options </li></ul></ul><ul><ul><li>Toolsets </li></ul></ul><ul><ul><li>Rule Management </li></ul></ul><ul><ul><li>Rule Modification </li></ul></ul><ul><ul><li>Sample Implementation </li></ul></ul>
  3. 3. Overview
  4. 4. Major Components <ul><ul><li>Working Memory/Sessions </li></ul></ul><ul><ul><ul><li>Rule Sets </li></ul></ul></ul><ul><ul><ul><ul><li>Packages </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Rules </li></ul></ul></ul></ul></ul><ul><ul><ul><li>Facts </li></ul></ul></ul><ul><ul><ul><li>Globals and Non Fact Objects </li></ul></ul></ul>
  5. 5. Working Memory <ul><ul><li>Stateful </li></ul></ul><ul><ul><li>Stateless </li></ul></ul><ul><ul><li>Can be dynamically updated </li></ul></ul><ul><ul><li>Data can push or pull between Working Memory </li></ul></ul>
  6. 6. Rule Sets <ul><ul><li>Contain groupings of Rule Packages </li></ul></ul><ul><ul><li>Are associated with a Session </li></ul></ul>
  7. 7. Packages <ul><ul><li>Contain sets of rules </li></ul></ul><ul><ul><li>Are serializable </li></ul></ul>
  8. 8. Rules <ul><ul><li>Come in various formats </li></ul></ul><ul><ul><ul><li>DRL/DSL </li></ul></ul></ul><ul><ul><ul><li>XML </li></ul></ul></ul><ul><ul><ul><li>Spreadsheet </li></ul></ul></ul><ul><ul><ul><li>BRMS </li></ul></ul></ul><ul><ul><ul><li>Spring annotated beans </li></ul></ul></ul><ul><ul><li>Are serializable </li></ul></ul><ul><ul><li>Loaded using various techniques </li></ul></ul>
  9. 9. XML Rule <!-- Check for XYZ Corp--> <rule name=&quot;XYZCorp&quot; salience=&quot;-1&quot;> <!-- Parameters we can pass into the business rule --> <parameter identifier=&quot;stockOffer&quot;> <class>StockOffer</class> </parameter> <!-- Conditions or 'Left Hand Side' (LHS) that must be met for business rule to fire --> <java:condition>stockOffer.getStockName().equals(&quot;XYZ&quot;)</java:condition> <java:condition>stockOffer.getRecommendPurchase() == null</java:condition> <java:condition>stockOffer.getStockPrice() &gt; 10</java:condition> <!-- What happens when the business rule is activated --> <java:consequence> stockOffer.setRecommendPurchase(StockOffer.NO); printStock(stockOffer); </java:consequence> </rule>
  10. 10. DRL Rule rule &quot;Time Zone One&quot; no-loop true when $w : WorkItem(address.state.value memberOf timeZoneOneStates); then $w.setPriority($w.getPriority()+ 128); end
  11. 11. Facts <ul><ul><li>Objects that Rules act upon </li></ul></ul><ul><ul><li>Follow Java Bean Rules </li></ul></ul><ul><ul><li>Can be dynamically updated </li></ul></ul><ul><ul><li>No limit to number, type or state of objects </li></ul></ul>
  12. 12. Global and Non Fact Objects <ul><ul><li>Used to provide data or functions </li></ul></ul><ul><ul><li>Injected during packaging </li></ul></ul><ul><ul><li>Can be any Java object </li></ul></ul><ul><ul><li>Accessible via any Rule Format </li></ul></ul>
  13. 13. Toolsets <ul><ul><li>Eclipse Based Development </li></ul></ul><ul><ul><li>Eclipse Based Debugging </li></ul></ul><ul><ul><li>Log Debugging </li></ul></ul>
  14. 14. Rule Management <ul><ul><li>File and/or classpath loading </li></ul></ul><ul><ul><li>JNDI Loading </li></ul></ul><ul><ul><li>Database Loading </li></ul></ul><ul><ul><li>Pre-Compilation (Rules are serializable) </li></ul></ul><ul><ul><li>Pre-Packaging (Packages are serializable) </li></ul></ul><ul><ul><li>Caching Strategies </li></ul></ul>
  15. 15. Rule Modification <ul><ul><li>Property or Database Driven </li></ul></ul><ul><ul><li>DSL based </li></ul></ul><ul><ul><li>BRMS based </li></ul></ul><ul><ul><li>XML Dynamic Modification </li></ul></ul>
  16. 16. Sample Implementation <ul><ul><li>Simple Replacement of existing Business Rule Interface </li></ul></ul><ul><ul><li>Code </li></ul></ul>
  17. 17. Problem Domain
  18. 18. Pros <ul><ul><li>Declarative Programming Model </li></ul></ul><ul><ul><ul><li>Concentrate on the what not the how </li></ul></ul></ul><ul><ul><li>Increased Performance </li></ul></ul><ul><ul><ul><li>Speed and Scalability </li></ul></ul></ul><ul><ul><li>Easily modified which increases coordination between business and IT </li></ul></ul><ul><ul><li>Separation of logic and data (Is this a good thing?) </li></ul></ul>
  19. 19. Cons <ul><ul><li>New thought processes </li></ul></ul><ul><ul><li>Somewhat black box </li></ul></ul><ul><ul><li>Separation of code and logic breaks OO paradigm. </li></ul></ul>
  20. 20. Spring Support Rule @Rule( name=&quot;Set Pump to Cooling&quot;, documentation=&quot;If a floors temperature becomes too hot, and the floor's pump is off, set the pump in the cooling state.&quot;, salience=10 ) public class PumpOffWhenFloorsWarmEnough {
  21. 21. Spring Support When @Condition public boolean isPumpOff(@Fact HeatPump pump) { return pump.getState() == OFF; }
  22. 22. Spring Support Then @Consequence public void consequence(HeatPump pump) { pump.setState(COOLING); }
  23. 23. Spring Configuration <bean id=&quot;pumpRuleSet&quot; class=&quot;org.drools.spring.factory.RuleSetFactoryBean&quot;> <property name=&quot;rules&quot;> <set> <bean id=&quot;pump.OffWhenFloorsCoolEnough&quot; ... /> <bean id=&quot;pump.OffWhenFloorsWarmEnough&quot; .../> <bean id=&quot;pump.HeatingWhenFloorTooCold&quot; .../> <bean id=&quot;pump.CoolingWhenFloorTooHot&quot; .../> </set> </property> </bean>

×