SlideShare a Scribd company logo
1 of 37
Download to read offline
BRMS: Best (and worst)
    Practices and Real World
            Examples

            Edson Tirelli
       Senior Software Engineer
          JBoss, by Red Hat




1                       Rules Fest – October 2011
It all starts with a question...




      What is the performance of <BRMS product name>?


2                                              Rules Fest – October 2011
Followed by...




        Are there any best practices (a.k.a blue prints) to
                   achieve performance <X>?

3                                                        Rules Fest – October 2011
Lets talk about blue prints...




      ... but first, lets open our eyes to everything rules engines
                              have to offer us!

4                                                         Rules Fest – October 2011
BRMS adoption goals




5                     Rules Fest – October 2011
A simple analogy




    Business Rules Engines   Databases
           (Rules)             (Data)




6                                Rules Fest – October 2011
BRMS: goals

    ●   Independent Lifecycle Management of Business Rules




7                                                  Rules Fest – October 2011
BRMS: goals

    ●   Declarative language for rules and queries
         ●   Focus on “what to do”, not “how to do it”

         rule “Send shipment pick-up SMS alert”
         rule “Send shipment pick-up SMS alert”
         when
         when
               There is a shipment order
               There is a shipment order
               There is a route assigned to the order
               There is a route assigned to the order
               There is a truck GPS reading and the truck is 15m from the pick-up location
               There is a truck GPS reading and the truck is 15m from the pick-up location
         then
         then
               Send SMS to customer: ARRIVING, “15 minutes”
               Send SMS to customer: ARRIVING, “15 minutes”
         end
         end




8                                                                                Rules Fest – October 2011
BRMS: goals

    ●   Logic, Data and Tasks split
    ●   Centralization of Knowledge
         ●   Consistency
         ●   Testing / Simulation   Knowledge                                            Knowledge
                                       Base                                                Session
         ●   Auditing               (production   Inference                               (working
                                     memory/       Engine                                 memory/
    ●   Explanation Facility           rules)                                            facts/data)



                                                              * Directly or Indirectly




                                                     Tasks
                                                   (services,
                                                  procedures,
                                                      etc)



9                                                                     Rules Fest – October 2011
BRMS: goals

     ●   Execution Performance and Scalability
          ●   Many-to-many pattern matching algorithm
          ●   Optimizes the whole set of rules
          ●   Performance is linear on the number of
              rules “touched” by each fact
          ●   Easily scales to tens of thousands of rules
          ●   Eager evaluation with incremental
              changes re-evaluation




10                                                          Rules Fest – October 2011
Under the hood




11               Rules Fest – October 2011
Rete in 30 seconds

     ●   Classic Rete algorithm “idea”
          ●   Discrimination network
          ●   Facts arrive at the top            Fact Types

          ●   Propagate down
          ●   If they reach the bottom,      Filter conditions
                                             (alpha network)

              corresponding rule activates
     ●   + Enables optimizations
     ●   + Enables additional feature set
                                             Join conditions
                                             (beta network)


                                                       Rules




12                                                               Rules Fest – October 2011
Typical Rete Optimizations

     ●   Support to POJOs as facts
          ●   no mapping/data copy necessary
     ●   Full split between KBase and Working Memory
          ●   lightweight session creation
          ●   knowledge base sharing
     ●   Completely Dynamic KBase management
          ●   Hot addition/removal/updates of rules/queries/processes
     ●   Full support to First Order Logic and Set operations
     ●   JIT compilation for constraints and data access



13                                                         Rules Fest – October 2011
Typical Rete Optimizations

     ●   Node Sharing (constraint sharing)


     ●   Alpha Hashing:
          ●   Provides O(1) performance for mutually exclusive constraints


     ●   Rule 1: Customer is GOLD
     ●   Rule 2: Customer is SILVER
                                             Uses a hash function instead of
     ●   Rule 3: Customer is BRONZE          checking each constraint

     ●   Rule x: Customer is XYZ



14                                                              Rules Fest – October 2011
Typical Rete Optimizations

     ●   Beta Memory Indexing:
          ●   Provides O(1) performance for joins
               Order( customerId == $someCustomer.id )

     ●   FOL lazy match:
          ●   Avoids wasted matching on FOL conditional elements
               exists( Customer( age > 50 ) )




15                                                       Rules Fest – October 2011
Typical Rete Optimizations: Visual Index


                                 Class type caching
                                 (+ inheritance support)
           Fact Types

                                 Node Sharing

      Filter conditions          Alpha Hashing
      (alpha network)




                                 FOL Lazy match

      Join conditions            Memory Indexing
      (beta network)
                                 Aggregations/Accumulations
                Rules




16                                           Rules Fest – October 2011
Best Practices




17               Rules Fest – October 2011
BRMS Best Practices

     ●   Don't try to micro-control rules execution
          ●   Use the Conflict Resolution Strategies instead
               ●   Salience
               ●   Agenda groups
               ●   Ruleflow
               ●   Dynamic enablement
                                              Knowledge                       Knowledge
                                                 Base                           Session
                                              (production   Inference          (working
                                               memory/       Engine            memory/
                                                 rules)                       facts/data)




                                                               Tasks
                                                             (services,
                                                            procedures,
                                                                etc)




18                                                             Rules Fest – October 2011
BRMS Best Practices

     ●   Partition your Knowledge Bases properly
          ●   Subject matter
          ●   Transaction / Service / Unit of Work
          ●   Business Entity
     ●   Avoid monolithic kbases
     ●   Avoid fine grained kbases
                                              Knowledge                       Knowledge
                                                 Base                           Session
                                              (production   Inference          (working
                                               memory/       Engine            memory/
                                                 rules)                       facts/data)




                                                               Tasks
                                                             (services,
                                                            procedures,
                                                                etc)




19                                                             Rules Fest – October 2011
BRMS Best Practices

     ●   Cache the Knowledge Base, share the sessions
          ●   Rules are usually JIT compiled at load time
          ●   Can be compiled at build time for non-dynamic use
              cases



                                              Knowledge                       Knowledge
                                                 Base                           Session
                                              (production   Inference          (working
                                               memory/       Engine            memory/
                                                 rules)                       facts/data)




                                                               Tasks
                                                             (services,
                                                            procedures,
                                                                etc)




20                                                             Rules Fest – October 2011
BRMS Best Practices

     ●   Don't overload rules
          ●   Each rule should describe one and only one
              scenario→action mapping
          ●   The engine will optimize shared conditions
          ●   The engine supports inference


 rule “Short sale”
 rule “Short sale”                                 rule “Refuse short sales”
                                                   rule “Refuse short sales”
 when
 when                                              when
                                                   when
         $ss : SecuritySaleOrder()
         $ss : SecuritySaleOrder()                       $ss : SecuritySaleOrder()
                                                         $ss : SecuritySaleOrder()
         not( Security( this == $ss.security ) )
         not( Security( this == $ss.security ) )         exists( ShortSale( this.ss == $ss ) )
                                                         exists( ShortSale( this.ss == $ss ) )
 then
 then                                              then
                                                   then
         // identify as a short sale
         // identify as a short sale                     // refuse order
                                                         // refuse order
         insert( new ShortSale( $ss ) );
         insert( new ShortSale( $ss ) );                 $ss.refuse();
                                                         $ss.refuse();
 end
 end                                               end
                                                   end




21                                                                             Rules Fest – October 2011
BRMS Best Practices

     ●   Avoid the use of “evals”
          ●   Harder for the engine to optimize
          ●   Harder for rule authors to maintain
     ●   Use engine features:
          ●   Pluggable operators
          ●   Annotations
          ●   ...     rule “Simultaneous calls from different places”
                      rule “Simultaneous calls from different places”
                            @system( “Fraud Detection” ) @requirementId( “FD001” )
                            @system( “Fraud Detection” ) @requirementId( “FD001” )
                      when
                      when
                            $c1 : VoiceCall()
                            $c1 : VoiceCall()
                            $c2 : VoiceCall( cust == $c1.cust, base != $c1.base,
                            $c2 : VoiceCall( cust == $c1.cust, base != $c1.base,
                                            base notAdjancent $c1.base )
                                            base notAdjancent $c1.base )
                      then
                      then
                            // possible fraud detected
                            // possible fraud detected
                      end
                      end


22                                                                             Rules Fest – October 2011
BRMS Best Practices

     ●   Batch data loads
          ●   It is usually faster to load 1000 facts and then fire the
              rules than fire rules after each inserted fact
     ●   Partition the data into multiple sessions
          ●   Transaction / Service / Unit of work
     ●   Creating a new session is cheap
                                                Knowledge                       Knowledge
          ●   Sometimes cheaper than               Base
                                                (production   Inference
                                                                                  Session
                                                                                 (working
                                                 memory/       Engine            memory/

              removing facts from existing         rules)                       facts/data)




              session.
                                                                 Tasks
                                                               (services,
                                                              procedures,
                                                                  etc)




23                                                               Rules Fest – October 2011
BRMS Best Practices

     ●   Quality of the data/fact model is directly proportional to the
         performance and maintainability of the rules using it
          ●   Think about the DBMS analogy
          ●   Flatter models improve performance
          ●   Smaller classes help avoiding recursions

                                              Knowledge                       Knowledge
                                                 Base                           Session
                                              (production   Inference          (working
                                               memory/       Engine            memory/
                                                 rules)                       facts/data)




                                                               Tasks
                                                             (services,
                                                            procedures,
                                                                etc)




24                                                             Rules Fest – October 2011
Best Practices in Rules Authoring




25                                  Rules Fest – October 2011
A Frog Rule: anything odd about it?
 rule “11111”
 rule “11111”
 # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in
 # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in
 # its logic, please do the same for rule #22222
 # its logic, please do the same for rule #22222
 when
 when
       # RULE CHANNEL MANDATORY SECTION
       # RULE CHANNEL MANDATORY SECTION
       ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
       ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
       # BUSINESS LOGIC
       # BUSINESS LOGIC
       Frog( color == “green” ) and
       Frog( color == “green” ) and
       ( #rule 22222
       ( #rule 22222
           Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) > 0 ) )
           Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) > 0 ) )
       ) || ( #rule 33333
       ) || ( #rule 33333
           Prince( name == “Charming”)
           Prince( name == “Charming”)
       ) || ( #rule 44444
       ) || ( #rule 44444
           ...
           ...
       )
       )
 then
 then
       // An empty “consequence”
       // An empty “consequence”
 end
 end



                 PS: lets focus on the structure of the rule and not the actual logic.

26                                                                              Rules Fest – October 2011
A Frog Rule: looks suspicious

                              Rule name as part of the logic?


 rule “11111”
 rule “11111”
 # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in
 # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in
 # its logic, please do the same for rule #22222
 # its logic, please do the same for rule #22222
 when
 when
       # RULE CHANNEL MANDATORY SECTION
       # RULE CHANNEL MANDATORY SECTION
       ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
       ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
       # BUSINESS LOGIC
       # BUSINESS LOGIC
                                            Use of control fact?
       Frog( color == “green” ) and
       Frog( color == “green” ) and
       ( #rule 22222
       ( #rule 22222
           Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) )
           Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) )
       ) || ( #rule 33333
       ) || ( #rule 33333
                                          “Embedded” rules?
           Prince( name == “Charming”)
           Prince( name == “Charming”)
       ) || ( #rule 44444
       ) || ( #rule 44444                                            Over use of evals?
           ...
           ...
       )
       )
 then
 then
       // An empty “consequence”
                                             Empty consequence?
       // An empty “consequence”
 end
 end


27                                                                              Rules Fest – October 2011
Why is an empty consequence bad?
 rule “11111”
 rule “11111”
 when
 when
       ...
       ...
 then
 then
       // An empty “consequence”
       // An empty “consequence”
 end
 end




       Breaks independent lifecycle management goal
       Breaks centralization of knowledge goal
       Breaks clarity goal (what to do?)
       Breaks explanation facility goal
       The Frog will never turn into a Prince
       Should this be a query instead?

28                                                Rules Fest – October 2011
Alternatives: Rules vs Queries

                                         Rules                   Queries
           Control           Invoked by the engine      Invoked by the application
           Parameters        Don't support parameters   Support parameters
           Results           Execute actions            Return results

 rule “Transform Frog into Prince”
 rule “Transform Frog into Prince”
 when
 when
       $f : Frog( color == “green” )
       $f : Frog( color == “green” )
 then
 then
       insert( new Prince( “Mark” ) );
       insert( new Prince( “Mark” ) );
       retract( $f );
       retract( $f );
 end
 end


 query “Get the frog”( $color )
 query “Get the frog”( $color )
 when
 when
       $f : Frog( color == $color )
       $f : Frog( color == $color )
 end
 end




29                                                                       Rules Fest – October 2011
Why is bad to use the rule name in
the logic?
 rule “11111”
 rule “11111”
 when
 when
     ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
     ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
     ...
     ...
     ( #rule 22222
     ( #rule 22222
     ...
     ...




     Breaks clarity goal
     Breaks “one scenario – one action” best practice
     Rule names must be unique within the knowledge base
     Usually leads to micro-control and procedural code




30                                                                            Rules Fest – October 2011
Alternatives for metadata declaration

 rule “11111 – transform the frog into a prince”
 rule “11111 – transform the frog into a prince”
       @requirementId( “11111” ) @author( “Mark” )
       @requirementId( “11111” ) @author( “Mark” )
       @relatedTo( “22222, 33333” )
       @relatedTo( “22222, 33333” )
       @documentation( “A rule with lots of annotations” )
       @documentation( “A rule with lots of annotations” )
 when
 when
       ...
       ...
 then
 then
       insert( new Prince( “Mark” ) );
       insert( new Prince( “Mark” ) );
       messenger.announceTheWedding( drools.getRule().getMetaData().get( “requirementId” ) );
       messenger.announceTheWedding( drools.getRule().getMetaData().get( “requirementId” ) );
 end
 end



       Use annotations
       Do not use metadata in conditions
       It is ok to use metadata in consequences
       If necessary, metadata is available to the enabled attribute

31                                                                              Rules Fest – October 2011
Why Control Facts should be avoided?
 rule “11111”
 rule “11111”
 when
 when
     ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
     ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true )
     ...
     ...
     ( #rule 22222
     ( #rule 22222
     ...
     ...




     Breaks clarity goal
     Breaks one scenario – one action best practice
     Leads to micro-control and procedural code
     Usually leads to runtime overhead
     Sometimes, control facts are useful, but not for the general
     case


32                                                                            Rules Fest – October 2011
Alternatives for control facts

 rule “11111 – transform the frog into a prince”
 rule “11111 – transform the frog into a prince”
     agenda-group “x”
     agenda-group “x”
     ruleflow-group “y”
     ruleflow-group “y”
     salience 10
                                                   Usually one of these attributes is enough
     salience 10
     enabled ( ... a boolean expression ... )
     enabled ( ... a boolean expression ... )
 when
 when
     ...
     ...




     Use rule attributes for conflict resolution
     Use enabled expressions to conditionally disable rules
     Do not abuse of salience
     Let the engine do its job




33                                                                         Rules Fest – October 2011
Why “embedded” rules are bad?
     ( #rule 22222
     ( #rule 22222
         Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) )
         Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) )
     ) || ( #rule 33333
     ) || ( #rule 33333
         Prince( name == “Charming”)
         Prince( name == “Charming”)
     ) || ( #rule 44444
     ) || ( #rule 44444
         ...
         ...
     )
     )




     Breaks independent lifecycle management
     Breaks clarity goal
     Breaks explanation facility goal
     Breaks performance goal
     Breaks one scenario – one action best practice
     Increases maintenance cost and testing complexity

34                                                                            Rules Fest – October 2011
Alternatives for “embedded rules”

 rule “11111.a – Teenagers are eligible”
 rule “11111.a – Teenagers are eligible”                    rule “11111.b – Elders are eligible”
                                                            rule “11111.b – Elders are eligible”
 when
 when                                                       when
                                                            when
       $p : Person( age >= 16 && <= 18 )
       $p : Person( age >= 16 && <= 18 )                          $p : Person( age >= 60 )
                                                                  $p : Person( age >= 60 )
 then
 then                                                       then
                                                            then
       insert( new Eligible( $p ) );
       insert( new Eligible( $p ) );                              insert( new Eligible( $p ) );
                                                                  insert( new Eligible( $p ) );
 end
 end                                                        end
                                                            end




                               rule “11111.c – Eligibles get discount”
                               rule “11111.c – Eligibles get discount”
                                     no-loop
                                     no-loop
                               when
                               when
                                     $t : Ticket()
                                     $t : Ticket()
                                     $e : Eligible()
                                     $e : Eligible()
                               then
                               then
                                     modify($t) { setDiscount( 0.25 ) }
                                     modify($t) { setDiscount( 0.25 ) }
                               end
                               end




35                                                                                 Rules Fest – October 2011
Alternatives for “embedded rules”

     One scenario – one action
     Allow the engine to do its job
     Take advantage of flow control features




36                                             Rules Fest – October 2011
Q&A


            Yes, we also do
           pair programming!




                     Edson Tirelli
                     etirelli@redhat.com
37                                 Rules Fest – October 2011

More Related Content

Viewers also liked

Application Architecture -Data, Process, Rule-
Application Architecture -Data, Process, Rule-Application Architecture -Data, Process, Rule-
Application Architecture -Data, Process, Rule-Masahiko Umeno
 
Zero to Hero Using Red Hat JBoss BRMS
Zero to Hero Using Red Hat JBoss BRMSZero to Hero Using Red Hat JBoss BRMS
Zero to Hero Using Red Hat JBoss BRMSEric D. Schabell
 
Online Free PEX Webinar - A Guide to Modern BPM Tools
Online Free PEX Webinar - A Guide to Modern BPM ToolsOnline Free PEX Webinar - A Guide to Modern BPM Tools
Online Free PEX Webinar - A Guide to Modern BPM ToolsEric D. Schabell
 
Generador de codigo lenguajes de programacion
Generador de codigo lenguajes de programacionGenerador de codigo lenguajes de programacion
Generador de codigo lenguajes de programacionbulnez
 
2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdl
2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdl2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdl
2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdlMike Marin
 
Business Rules - Design and Modeling Guidelines
Business Rules - Design and Modeling GuidelinesBusiness Rules - Design and Modeling Guidelines
Business Rules - Design and Modeling GuidelinesKeshav Deshpande
 
Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14
Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14
Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14said missoum
 
หน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพ
หน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพหน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพ
หน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพอัยเหี้ยม ยัยห้อย
 
Business rule and decision engine
Business rule and decision engineBusiness rule and decision engine
Business rule and decision enginePliant Framework
 
Business rules management system
Business rules management systemBusiness rules management system
Business rules management systemPliant Framework
 
Decision services for soa platforms
Decision services for soa platformsDecision services for soa platforms
Decision services for soa platformsPliant Framework
 
Building highly scalable process and rule-driven applications with JBoss Ente...
Building highly scalable process and rule-driven applications with JBoss Ente...Building highly scalable process and rule-driven applications with JBoss Ente...
Building highly scalable process and rule-driven applications with JBoss Ente...Eric D. Schabell
 
Semantically-Enabled Business Process Management
Semantically-Enabled Business Process ManagementSemantically-Enabled Business Process Management
Semantically-Enabled Business Process ManagementAdrian Paschke
 
การจัดการคุณภาพ 1
การจัดการคุณภาพ 1การจัดการคุณภาพ 1
การจัดการคุณภาพ 1Thida Noodaeng
 
Marketo LaunchPoint
Marketo LaunchPoint Marketo LaunchPoint
Marketo LaunchPoint Marketo
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyMark Proctor
 
Bpms ecu2014
Bpms ecu2014Bpms ecu2014
Bpms ecu2014Bob Brodt
 
การบริหารงานคุณภาพ Tqm
การบริหารงานคุณภาพ Tqmการบริหารงานคุณภาพ Tqm
การบริหารงานคุณภาพ TqmBoohsapun Thopkuntho
 

Viewers also liked (20)

Application Architecture -Data, Process, Rule-
Application Architecture -Data, Process, Rule-Application Architecture -Data, Process, Rule-
Application Architecture -Data, Process, Rule-
 
Zero to Hero Using Red Hat JBoss BRMS
Zero to Hero Using Red Hat JBoss BRMSZero to Hero Using Red Hat JBoss BRMS
Zero to Hero Using Red Hat JBoss BRMS
 
Online Free PEX Webinar - A Guide to Modern BPM Tools
Online Free PEX Webinar - A Guide to Modern BPM ToolsOnline Free PEX Webinar - A Guide to Modern BPM Tools
Online Free PEX Webinar - A Guide to Modern BPM Tools
 
Generador de codigo lenguajes de programacion
Generador de codigo lenguajes de programacionGenerador de codigo lenguajes de programacion
Generador de codigo lenguajes de programacion
 
2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdl
2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdl2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdl
2007 11-09 mm (costa rica - incae cit omg) modeling with bpmn and xpdl
 
Business Rules - Design and Modeling Guidelines
Business Rules - Design and Modeling GuidelinesBusiness Rules - Design and Modeling Guidelines
Business Rules - Design and Modeling Guidelines
 
Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14
Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14
Qwr iso20000 auditor m04 implementing audit and tooling us 06 apr14
 
หน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพ
หน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพหน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพ
หน่วยที่1 แนวคิดเกี่ยวกับการจัดการคุณภาพ
 
Business rule and decision engine
Business rule and decision engineBusiness rule and decision engine
Business rule and decision engine
 
L4
L4L4
L4
 
Business rules management system
Business rules management systemBusiness rules management system
Business rules management system
 
Decision services for soa platforms
Decision services for soa platformsDecision services for soa platforms
Decision services for soa platforms
 
Building highly scalable process and rule-driven applications with JBoss Ente...
Building highly scalable process and rule-driven applications with JBoss Ente...Building highly scalable process and rule-driven applications with JBoss Ente...
Building highly scalable process and rule-driven applications with JBoss Ente...
 
Semantically-Enabled Business Process Management
Semantically-Enabled Business Process ManagementSemantically-Enabled Business Process Management
Semantically-Enabled Business Process Management
 
การจัดการคุณภาพ 1
การจัดการคุณภาพ 1การจัดการคุณภาพ 1
การจัดการคุณภาพ 1
 
101ch6
101ch6101ch6
101ch6
 
Marketo LaunchPoint
Marketo LaunchPoint Marketo LaunchPoint
Marketo LaunchPoint
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
 
Bpms ecu2014
Bpms ecu2014Bpms ecu2014
Bpms ecu2014
 
การบริหารงานคุณภาพ Tqm
การบริหารงานคุณภาพ Tqmการบริหารงานคุณภาพ Tqm
การบริหารงานคุณภาพ Tqm
 

Similar to Brms best practices_2011_oct_final

JBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic PlatformJBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic Platformelliando dias
 
10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...
10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...
10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...SL Corporation
 
Strata + Hadoop 2015 Slides
Strata + Hadoop 2015 SlidesStrata + Hadoop 2015 Slides
Strata + Hadoop 2015 SlidesJun Liu
 
Measuring web performance. Velocity EU 2011
Measuring web performance. Velocity EU 2011Measuring web performance. Velocity EU 2011
Measuring web performance. Velocity EU 2011Stephen Thair
 
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011darach
 
Complex Er[jl]ang Processing with StreamBase
Complex Er[jl]ang Processing with StreamBaseComplex Er[jl]ang Processing with StreamBase
Complex Er[jl]ang Processing with StreamBasedarach
 
DTrace talk at Oracle Open World
DTrace talk at Oracle Open WorldDTrace talk at Oracle Open World
DTrace talk at Oracle Open WorldAngelo Rajadurai
 
IT Future 2012 - Fujitsu SAP HANA
IT Future 2012 - Fujitsu SAP HANA IT Future 2012 - Fujitsu SAP HANA
IT Future 2012 - Fujitsu SAP HANA Fujitsu France
 
Dynamics CRM high volume systems - lessons from the field
Dynamics CRM high volume systems - lessons from the fieldDynamics CRM high volume systems - lessons from the field
Dynamics CRM high volume systems - lessons from the fieldStéphane Dorrekens
 
Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...
Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...
Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...Alluxio, Inc.
 
Ruleml2012 - A production rule-based framework for causal and epistemic reaso...
Ruleml2012 - A production rule-based framework for causal and epistemic reaso...Ruleml2012 - A production rule-based framework for causal and epistemic reaso...
Ruleml2012 - A production rule-based framework for causal and epistemic reaso...RuleML
 
Ebs performance tune2_con9030_pdf_9030_0002
Ebs performance tune2_con9030_pdf_9030_0002Ebs performance tune2_con9030_pdf_9030_0002
Ebs performance tune2_con9030_pdf_9030_0002jucaab
 
Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...
Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...
Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...Intel® Software
 
Emakina Academy - 5 - Know your audience - Web Analytics
Emakina Academy -  5 - Know your audience - Web AnalyticsEmakina Academy -  5 - Know your audience - Web Analytics
Emakina Academy - 5 - Know your audience - Web AnalyticsEmakina
 
Hadoop, hive和scribe在运维方面的应用
Hadoop, hive和scribe在运维方面的应用Hadoop, hive和scribe在运维方面的应用
Hadoop, hive和scribe在运维方面的应用xshadowxc
 
Monitoreo y análisis de aplicaciones "Multi-Tier"
Monitoreo y análisis de aplicaciones "Multi-Tier"Monitoreo y análisis de aplicaciones "Multi-Tier"
Monitoreo y análisis de aplicaciones "Multi-Tier"GeneXus
 

Similar to Brms best practices_2011_oct_final (20)

JBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic PlatformJBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic Platform
 
10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...
10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...
10 Tricks to Ensure Your Oracle Coherence Cluster is Not a "Black Box" in Pro...
 
Strata + Hadoop 2015 Slides
Strata + Hadoop 2015 SlidesStrata + Hadoop 2015 Slides
Strata + Hadoop 2015 Slides
 
Measuring web performance. Velocity EU 2011
Measuring web performance. Velocity EU 2011Measuring web performance. Velocity EU 2011
Measuring web performance. Velocity EU 2011
 
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011
 
Complex Er[jl]ang Processing with StreamBase
Complex Er[jl]ang Processing with StreamBaseComplex Er[jl]ang Processing with StreamBase
Complex Er[jl]ang Processing with StreamBase
 
DTrace talk at Oracle Open World
DTrace talk at Oracle Open WorldDTrace talk at Oracle Open World
DTrace talk at Oracle Open World
 
IT Future 2012 - Fujitsu SAP HANA
IT Future 2012 - Fujitsu SAP HANA IT Future 2012 - Fujitsu SAP HANA
IT Future 2012 - Fujitsu SAP HANA
 
Dynamics CRM high volume systems - lessons from the field
Dynamics CRM high volume systems - lessons from the fieldDynamics CRM high volume systems - lessons from the field
Dynamics CRM high volume systems - lessons from the field
 
Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...
Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...
Intel: How to Use Alluxio to Accelerate BigData Analytics on the Cloud and Ne...
 
Ruleml2012 - A production rule-based framework for causal and epistemic reaso...
Ruleml2012 - A production rule-based framework for causal and epistemic reaso...Ruleml2012 - A production rule-based framework for causal and epistemic reaso...
Ruleml2012 - A production rule-based framework for causal and epistemic reaso...
 
Synopsys jul1411
Synopsys jul1411Synopsys jul1411
Synopsys jul1411
 
Ebs performance tune2_con9030_pdf_9030_0002
Ebs performance tune2_con9030_pdf_9030_0002Ebs performance tune2_con9030_pdf_9030_0002
Ebs performance tune2_con9030_pdf_9030_0002
 
Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...
Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...
Unleashing Intel® Advanced Vector Extensions 512 (Intel® AVX-512) Inside the ...
 
Drools
DroolsDrools
Drools
 
Dtrace Overview
Dtrace OverviewDtrace Overview
Dtrace Overview
 
Emakina Academy - 5 - Know your audience - Web Analytics
Emakina Academy -  5 - Know your audience - Web AnalyticsEmakina Academy -  5 - Know your audience - Web Analytics
Emakina Academy - 5 - Know your audience - Web Analytics
 
2011 10-26 bpm-talk_andrew_watson
2011 10-26 bpm-talk_andrew_watson2011 10-26 bpm-talk_andrew_watson
2011 10-26 bpm-talk_andrew_watson
 
Hadoop, hive和scribe在运维方面的应用
Hadoop, hive和scribe在运维方面的应用Hadoop, hive和scribe在运维方面的应用
Hadoop, hive和scribe在运维方面的应用
 
Monitoreo y análisis de aplicaciones "Multi-Tier"
Monitoreo y análisis de aplicaciones "Multi-Tier"Monitoreo y análisis de aplicaciones "Multi-Tier"
Monitoreo y análisis de aplicaciones "Multi-Tier"
 

Recently uploaded

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 

Recently uploaded (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Brms best practices_2011_oct_final

  • 1. BRMS: Best (and worst) Practices and Real World Examples Edson Tirelli Senior Software Engineer JBoss, by Red Hat 1 Rules Fest – October 2011
  • 2. It all starts with a question... What is the performance of <BRMS product name>? 2 Rules Fest – October 2011
  • 3. Followed by... Are there any best practices (a.k.a blue prints) to achieve performance <X>? 3 Rules Fest – October 2011
  • 4. Lets talk about blue prints... ... but first, lets open our eyes to everything rules engines have to offer us! 4 Rules Fest – October 2011
  • 5. BRMS adoption goals 5 Rules Fest – October 2011
  • 6. A simple analogy Business Rules Engines Databases (Rules) (Data) 6 Rules Fest – October 2011
  • 7. BRMS: goals ● Independent Lifecycle Management of Business Rules 7 Rules Fest – October 2011
  • 8. BRMS: goals ● Declarative language for rules and queries ● Focus on “what to do”, not “how to do it” rule “Send shipment pick-up SMS alert” rule “Send shipment pick-up SMS alert” when when There is a shipment order There is a shipment order There is a route assigned to the order There is a route assigned to the order There is a truck GPS reading and the truck is 15m from the pick-up location There is a truck GPS reading and the truck is 15m from the pick-up location then then Send SMS to customer: ARRIVING, “15 minutes” Send SMS to customer: ARRIVING, “15 minutes” end end 8 Rules Fest – October 2011
  • 9. BRMS: goals ● Logic, Data and Tasks split ● Centralization of Knowledge ● Consistency ● Testing / Simulation Knowledge Knowledge Base Session ● Auditing (production Inference (working memory/ Engine memory/ ● Explanation Facility rules) facts/data) * Directly or Indirectly Tasks (services, procedures, etc) 9 Rules Fest – October 2011
  • 10. BRMS: goals ● Execution Performance and Scalability ● Many-to-many pattern matching algorithm ● Optimizes the whole set of rules ● Performance is linear on the number of rules “touched” by each fact ● Easily scales to tens of thousands of rules ● Eager evaluation with incremental changes re-evaluation 10 Rules Fest – October 2011
  • 11. Under the hood 11 Rules Fest – October 2011
  • 12. Rete in 30 seconds ● Classic Rete algorithm “idea” ● Discrimination network ● Facts arrive at the top Fact Types ● Propagate down ● If they reach the bottom, Filter conditions (alpha network) corresponding rule activates ● + Enables optimizations ● + Enables additional feature set Join conditions (beta network) Rules 12 Rules Fest – October 2011
  • 13. Typical Rete Optimizations ● Support to POJOs as facts ● no mapping/data copy necessary ● Full split between KBase and Working Memory ● lightweight session creation ● knowledge base sharing ● Completely Dynamic KBase management ● Hot addition/removal/updates of rules/queries/processes ● Full support to First Order Logic and Set operations ● JIT compilation for constraints and data access 13 Rules Fest – October 2011
  • 14. Typical Rete Optimizations ● Node Sharing (constraint sharing) ● Alpha Hashing: ● Provides O(1) performance for mutually exclusive constraints ● Rule 1: Customer is GOLD ● Rule 2: Customer is SILVER Uses a hash function instead of ● Rule 3: Customer is BRONZE checking each constraint ● Rule x: Customer is XYZ 14 Rules Fest – October 2011
  • 15. Typical Rete Optimizations ● Beta Memory Indexing: ● Provides O(1) performance for joins Order( customerId == $someCustomer.id ) ● FOL lazy match: ● Avoids wasted matching on FOL conditional elements exists( Customer( age > 50 ) ) 15 Rules Fest – October 2011
  • 16. Typical Rete Optimizations: Visual Index Class type caching (+ inheritance support) Fact Types Node Sharing Filter conditions Alpha Hashing (alpha network) FOL Lazy match Join conditions Memory Indexing (beta network) Aggregations/Accumulations Rules 16 Rules Fest – October 2011
  • 17. Best Practices 17 Rules Fest – October 2011
  • 18. BRMS Best Practices ● Don't try to micro-control rules execution ● Use the Conflict Resolution Strategies instead ● Salience ● Agenda groups ● Ruleflow ● Dynamic enablement Knowledge Knowledge Base Session (production Inference (working memory/ Engine memory/ rules) facts/data) Tasks (services, procedures, etc) 18 Rules Fest – October 2011
  • 19. BRMS Best Practices ● Partition your Knowledge Bases properly ● Subject matter ● Transaction / Service / Unit of Work ● Business Entity ● Avoid monolithic kbases ● Avoid fine grained kbases Knowledge Knowledge Base Session (production Inference (working memory/ Engine memory/ rules) facts/data) Tasks (services, procedures, etc) 19 Rules Fest – October 2011
  • 20. BRMS Best Practices ● Cache the Knowledge Base, share the sessions ● Rules are usually JIT compiled at load time ● Can be compiled at build time for non-dynamic use cases Knowledge Knowledge Base Session (production Inference (working memory/ Engine memory/ rules) facts/data) Tasks (services, procedures, etc) 20 Rules Fest – October 2011
  • 21. BRMS Best Practices ● Don't overload rules ● Each rule should describe one and only one scenario→action mapping ● The engine will optimize shared conditions ● The engine supports inference rule “Short sale” rule “Short sale” rule “Refuse short sales” rule “Refuse short sales” when when when when $ss : SecuritySaleOrder() $ss : SecuritySaleOrder() $ss : SecuritySaleOrder() $ss : SecuritySaleOrder() not( Security( this == $ss.security ) ) not( Security( this == $ss.security ) ) exists( ShortSale( this.ss == $ss ) ) exists( ShortSale( this.ss == $ss ) ) then then then then // identify as a short sale // identify as a short sale // refuse order // refuse order insert( new ShortSale( $ss ) ); insert( new ShortSale( $ss ) ); $ss.refuse(); $ss.refuse(); end end end end 21 Rules Fest – October 2011
  • 22. BRMS Best Practices ● Avoid the use of “evals” ● Harder for the engine to optimize ● Harder for rule authors to maintain ● Use engine features: ● Pluggable operators ● Annotations ● ... rule “Simultaneous calls from different places” rule “Simultaneous calls from different places” @system( “Fraud Detection” ) @requirementId( “FD001” ) @system( “Fraud Detection” ) @requirementId( “FD001” ) when when $c1 : VoiceCall() $c1 : VoiceCall() $c2 : VoiceCall( cust == $c1.cust, base != $c1.base, $c2 : VoiceCall( cust == $c1.cust, base != $c1.base, base notAdjancent $c1.base ) base notAdjancent $c1.base ) then then // possible fraud detected // possible fraud detected end end 22 Rules Fest – October 2011
  • 23. BRMS Best Practices ● Batch data loads ● It is usually faster to load 1000 facts and then fire the rules than fire rules after each inserted fact ● Partition the data into multiple sessions ● Transaction / Service / Unit of work ● Creating a new session is cheap Knowledge Knowledge ● Sometimes cheaper than Base (production Inference Session (working memory/ Engine memory/ removing facts from existing rules) facts/data) session. Tasks (services, procedures, etc) 23 Rules Fest – October 2011
  • 24. BRMS Best Practices ● Quality of the data/fact model is directly proportional to the performance and maintainability of the rules using it ● Think about the DBMS analogy ● Flatter models improve performance ● Smaller classes help avoiding recursions Knowledge Knowledge Base Session (production Inference (working memory/ Engine memory/ rules) facts/data) Tasks (services, procedures, etc) 24 Rules Fest – October 2011
  • 25. Best Practices in Rules Authoring 25 Rules Fest – October 2011
  • 26. A Frog Rule: anything odd about it? rule “11111” rule “11111” # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in # its logic, please do the same for rule #22222 # its logic, please do the same for rule #22222 when when # RULE CHANNEL MANDATORY SECTION # RULE CHANNEL MANDATORY SECTION ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) # BUSINESS LOGIC # BUSINESS LOGIC Frog( color == “green” ) and Frog( color == “green” ) and ( #rule 22222 ( #rule 22222 Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) > 0 ) ) Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) > 0 ) ) ) || ( #rule 33333 ) || ( #rule 33333 Prince( name == “Charming”) Prince( name == “Charming”) ) || ( #rule 44444 ) || ( #rule 44444 ... ... ) ) then then // An empty “consequence” // An empty “consequence” end end PS: lets focus on the structure of the rule and not the actual logic. 26 Rules Fest – October 2011
  • 27. A Frog Rule: looks suspicious Rule name as part of the logic? rule “11111” rule “11111” # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in # NOTE: Please note that this rule is associated with rule #22222. If you make any changes in # its logic, please do the same for rule #22222 # its logic, please do the same for rule #22222 when when # RULE CHANNEL MANDATORY SECTION # RULE CHANNEL MANDATORY SECTION ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) # BUSINESS LOGIC # BUSINESS LOGIC Use of control fact? Frog( color == “green” ) and Frog( color == “green” ) and ( #rule 22222 ( #rule 22222 Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) ) Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) ) ) || ( #rule 33333 ) || ( #rule 33333 “Embedded” rules? Prince( name == “Charming”) Prince( name == “Charming”) ) || ( #rule 44444 ) || ( #rule 44444 Over use of evals? ... ... ) ) then then // An empty “consequence” Empty consequence? // An empty “consequence” end end 27 Rules Fest – October 2011
  • 28. Why is an empty consequence bad? rule “11111” rule “11111” when when ... ... then then // An empty “consequence” // An empty “consequence” end end Breaks independent lifecycle management goal Breaks centralization of knowledge goal Breaks clarity goal (what to do?) Breaks explanation facility goal The Frog will never turn into a Prince Should this be a query instead? 28 Rules Fest – October 2011
  • 29. Alternatives: Rules vs Queries Rules Queries Control Invoked by the engine Invoked by the application Parameters Don't support parameters Support parameters Results Execute actions Return results rule “Transform Frog into Prince” rule “Transform Frog into Prince” when when $f : Frog( color == “green” ) $f : Frog( color == “green” ) then then insert( new Prince( “Mark” ) ); insert( new Prince( “Mark” ) ); retract( $f ); retract( $f ); end end query “Get the frog”( $color ) query “Get the frog”( $color ) when when $f : Frog( color == $color ) $f : Frog( color == $color ) end end 29 Rules Fest – October 2011
  • 30. Why is bad to use the rule name in the logic? rule “11111” rule “11111” when when ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) ... ... ( #rule 22222 ( #rule 22222 ... ... Breaks clarity goal Breaks “one scenario – one action” best practice Rule names must be unique within the knowledge base Usually leads to micro-control and procedural code 30 Rules Fest – October 2011
  • 31. Alternatives for metadata declaration rule “11111 – transform the frog into a prince” rule “11111 – transform the frog into a prince” @requirementId( “11111” ) @author( “Mark” ) @requirementId( “11111” ) @author( “Mark” ) @relatedTo( “22222, 33333” ) @relatedTo( “22222, 33333” ) @documentation( “A rule with lots of annotations” ) @documentation( “A rule with lots of annotations” ) when when ... ... then then insert( new Prince( “Mark” ) ); insert( new Prince( “Mark” ) ); messenger.announceTheWedding( drools.getRule().getMetaData().get( “requirementId” ) ); messenger.announceTheWedding( drools.getRule().getMetaData().get( “requirementId” ) ); end end Use annotations Do not use metadata in conditions It is ok to use metadata in consequences If necessary, metadata is available to the enabled attribute 31 Rules Fest – October 2011
  • 32. Why Control Facts should be avoided? rule “11111” rule “11111” when when ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) ControlFact( a[“11111”].b[this.X].enabled == true, a[“11111”].s[this.S] == true ) ... ... ( #rule 22222 ( #rule 22222 ... ... Breaks clarity goal Breaks one scenario – one action best practice Leads to micro-control and procedural code Usually leads to runtime overhead Sometimes, control facts are useful, but not for the general case 32 Rules Fest – October 2011
  • 33. Alternatives for control facts rule “11111 – transform the frog into a prince” rule “11111 – transform the frog into a prince” agenda-group “x” agenda-group “x” ruleflow-group “y” ruleflow-group “y” salience 10 Usually one of these attributes is enough salience 10 enabled ( ... a boolean expression ... ) enabled ( ... a boolean expression ... ) when when ... ... Use rule attributes for conflict resolution Use enabled expressions to conditionally disable rules Do not abuse of salience Let the engine do its job 33 Rules Fest – October 2011
  • 34. Why “embedded” rules are bad? ( #rule 22222 ( #rule 22222 Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) ) Frog( eval( height.bigDecimalValue.compareTo( somePrince.height.bigDecimalValue ) < 0 ) ) ) || ( #rule 33333 ) || ( #rule 33333 Prince( name == “Charming”) Prince( name == “Charming”) ) || ( #rule 44444 ) || ( #rule 44444 ... ... ) ) Breaks independent lifecycle management Breaks clarity goal Breaks explanation facility goal Breaks performance goal Breaks one scenario – one action best practice Increases maintenance cost and testing complexity 34 Rules Fest – October 2011
  • 35. Alternatives for “embedded rules” rule “11111.a – Teenagers are eligible” rule “11111.a – Teenagers are eligible” rule “11111.b – Elders are eligible” rule “11111.b – Elders are eligible” when when when when $p : Person( age >= 16 && <= 18 ) $p : Person( age >= 16 && <= 18 ) $p : Person( age >= 60 ) $p : Person( age >= 60 ) then then then then insert( new Eligible( $p ) ); insert( new Eligible( $p ) ); insert( new Eligible( $p ) ); insert( new Eligible( $p ) ); end end end end rule “11111.c – Eligibles get discount” rule “11111.c – Eligibles get discount” no-loop no-loop when when $t : Ticket() $t : Ticket() $e : Eligible() $e : Eligible() then then modify($t) { setDiscount( 0.25 ) } modify($t) { setDiscount( 0.25 ) } end end 35 Rules Fest – October 2011
  • 36. Alternatives for “embedded rules” One scenario – one action Allow the engine to do its job Take advantage of flow control features 36 Rules Fest – October 2011
  • 37. Q&A Yes, we also do pair programming! Edson Tirelli etirelli@redhat.com 37 Rules Fest – October 2011