JBoss Enterprise BRMSBuilding highly scalable process and rule-driven applications                     Eric D. Schabell   ...
Developing BRMS Applications that Scale    ●   Overview    ●   BRMS Adoption Goals    ●   Under the Hood    ●   Best Pract...
JBoss Enterprise BRMS                                                                                                Busin...
JBoss Enterprise BRMS                                                                                              Busines...
JBoss Enterprise BRMS                                                                                                Busin...
JBoss Enterprise BRMS                                                                                              Busines...
JBoss Enterprise BRMS                                                                                                Busin...
BRMS adoption goals8
Goal #1: Decision Automation                                                    Conclusion: Time is Money!                ...
Goal #2: Expressiveness and Visibility rule “Send shipment pick-up SMS alert” rule “Send shipment pick-up SMS alert” when ...
Goal #3: Performance and Scalability     ●   Real time, online, systems          ●   Millisecond response times     ●   Hu...
Goal #4..#6: other technical goals     ●   Logic, Data and Tasks split     ●   Centralization of Knowledge          ●   Co...
JBoss BRMS: under the hood13
Engines Algorithm – 30 seconds crash course                                                         Rete Network: Computer...
JBoss BRMS – some optimizations     ●   Support to POJOs as facts          ●   no mapping/data copy necessary     ●   Full...
JBoss BRMS – More optimizations                                                      Data         Alpha Hashing           ...
JBoss Enterprise BRMS17
Best Practices – BPM Architecture                                          Interaction Layer                              ...
Best Practices – Process Initialization                     EJB      MDB     ●   How do you start your process?           ...
Process Implementation LayerBest Practices – Process Implementation     ●   Java nodes          ●   do you keep it clean? ...
Best Practices – Process Interaction     ●   Processes interact with your Enterprise          ●   Web Services, EJB, GUI, ...
Best Practices – Always good BPM practices...     ●   Simplify everything (KISS)          ●   apply OO to process design  ...
Best Practices – Rule Architecture     ●   Partition your Knowledge Bases properly          ●   Subject matter          ● ...
Best Practices – Rule Architecture     ●   Batch data loads          ●   Load 1000 facts and fire the rules faster than fi...
Best Practices – Rule Architecture     ●   Quality of the data/fact model is directly proportional to the         performa...
JBoss BRMS – Best Practices in Rules Authoring26
Best Practices – Rules Authoring     ●   Dont try to micro-control rules execution          ●   Use the Conflict Resolutio...
Best Practices – Rules Authoring     ●   Dont overload rules          ●   Each rule should describe one and only one      ...
Best Bad Practices – Rules Authoring       rule “1 – Teenagers and Elders get Discount”       rule “1 – Teenagers and Elde...
Best Practices – Rules Authoringrule “0.a – Teenagers are 16-18”rule “0.a – Teenagers are 16-18”                rule “0.b ...
Best Practices – Rules Authoring     ●   One calculation (accumulate) per rule           ●   Accumulates have O(n) perform...
Best Practices – Rules Authoring     ●    Rules vs Queries                                                Rules           ...
Best Practices – Rules Authoring     ●   Declared Types          ●   Facts used only by the rules          ●   Facts that ...
Add references●    JBoss Enterprise BRMS Best Practices Guide     http://www.redhat.com/promo/integrated_enterprise/brms-b...
Questions?
Upcoming SlideShare
Loading in …5
×

Building highly scalable process and rule-driven applications with JBoss Enterprise BRMS

2,484 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,484
On SlideShare
0
From Embeds
0
Number of Embeds
925
Actions
Shares
0
Downloads
38
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Building highly scalable process and rule-driven applications with JBoss Enterprise BRMS

  1. 1. JBoss Enterprise BRMSBuilding highly scalable process and rule-driven applications Eric D. Schabell JBoss Technology Evangelist
  2. 2. Developing BRMS Applications that Scale ● Overview ● BRMS Adoption Goals ● Under the Hood ● Best Practices ● BPM ● Architecture ● Rules Authoring2
  3. 3. JBoss Enterprise BRMS Business Events Interacts Web-based Decision with... Enterprise development tools Service ApplicationBusiness Analysts Web Event Processor Repository Service Deploy Business Process Business Business Process Rule & Manager Definitions Event Definitions Java Code Rule Engine JBDS, with BRMS r plugins i to on M & ge ana M Business Developers Users Management Business Console Data Operations 3
  4. 4. JBoss Enterprise BRMS Business Events Interacts Web-based Decision with... Enterprise development tools Service ApplicationBusiness Analysts Web Event Processor Repository Service Deploy Business Process Business Business Process Rule & Manager Definitions Event Definitions Java Code Rule Engine JBDS, with BRMS r plugins i to on M & ge ana M Business Developers Users Management Business Console Data Operations 4
  5. 5. JBoss Enterprise BRMS Business Events Interacts Web-based Decision with... Enterprise development tools Service ApplicationBusiness Analysts Web Event Processor Repository Service Deploy Business Process Business Business Process Rule & Manager Definitions Event Definitions Java Code Rule Engine JBDS, with BRMS r plugins i to on M & ge ana M Business Developers Users Management Business Console Data Operations 5
  6. 6. JBoss Enterprise BRMS Business Events Interacts Web-based with... development tools Decision Enterprise (Guvnor) Service ApplicationBusiness Analysts Web Event Processor Repository Service Deploy Business Process Business Business Process Rule & Manager Definitions Event Definitions Java Code Rule Engine JBDS, with BRMS r plugins i to on M & ge ana M Business Developers Users Management Business Console Data Operations 6
  7. 7. JBoss Enterprise BRMS Business Events Interacts Web-based Decision with... Enterprise development tools Service ApplicationBusiness Analysts Web Event Processor Repository Service Deploy Business Process Business Business Process Rule & Manager Definitions Event Definitions Java Code Rule Engine JBDS, with BRMS r plugins i to on M & ge ana M Business Developers Users Management Business Console Data Operations 7
  8. 8. BRMS adoption goals8
  9. 9. Goal #1: Decision Automation Conclusion: Time is Money! Business Event Value Loss Business Value Reaction Time Time Loss Adapted from a presentation by James Taylor, Sep/20119
  10. 10. Goal #2: Expressiveness and Visibility 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 There is a route assigned to the order the order There is a truck GPS reading There is a truck GPS reading and the truck is 15 minutes and the truck is 15 minutes away from the pick-up location away from the pick-up location then then Send SMS to customer: “Arriving in 15 minutes” Send SMS to customer: “Arriving in 15 minutes” end end Focus on “what to do” instead of “how to do it”10
  11. 11. Goal #3: Performance and Scalability ● Real time, online, systems ● Millisecond response times ● Hundreds of thousands of rules ● JBoss BRMS: 700k+ rules ● Millions of data instances (facts) ● Incremental (re-)evaluation ● Changes in data cant reset reasoning11
  12. 12. Goal #4..#6: other technical goals ● Logic, Data and Tasks split ● Centralization of Knowledge ● Consistency ● Testing / Simulation Knowledge Knowledge ● Auditing Base (rules/events/ Inference Session Engine (data) processes) ● Explanation Facility Tasks12
  13. 13. JBoss BRMS: under the hood13
  14. 14. Engines Algorithm – 30 seconds crash course Rete Network: Computers View Data Customer Order Decision Table: Users View Customer Order Total Discount Amount < $1000 >=$1000Gold 15% Gold SilverSilver < $1000 5%Silver >= $1000 10% Clear, Concise, Objective Discount: 15% Discount: 5% Discount: 10% Efficient, Effective14
  15. 15. JBoss BRMS – some optimizations ● Support to POJOs as facts ● no mapping/data copy necessary ● Full split between Knowledge Base and Session ● lightweight session creation ● knowledge base sharing ● Completely Dynamic Knowledge Base ● Hot addition/removal/updates of rules/queries/processes ● Full support to First Order Logic and Set operations ● JIT compilation for constraints and data access15
  16. 16. JBoss BRMS – More optimizations Data Alpha Hashing Customer Order Node Sharing Gold Silver < $1000 >=$1000 Data Indexing Lazy Matching Discount: 15% Discount: 5% Discount: 10%16
  17. 17. JBoss Enterprise BRMS17
  18. 18. Best Practices – BPM Architecture Interaction Layer EJB / POJO ESB Web Services Human Tasks Process Implementation Layer JBPM Console Reporting, BAM Dashboards Process RepositoryQueues Process Initialization Layer BPMN2 Authoring for BPMN2 Authoring for Business Users Developers Developer 18 Customer
  19. 19. Best Practices – Process Initialization EJB MDB ● How do you start your process? Queues ● web services, EJBs, API call, RESTful ● what about prioritization of processes Process Initialization Layer ● use message queues ● other complex ideas to start processes ● Centralize startProcess in single location ● minimizes change effects in this layer Customer19
  20. 20. Process Implementation LayerBest Practices – Process Implementation ● Java nodes ● do you keep it clean? ● single unit of action per process step ● human task / admin interfaces ● Centralize you jBPM API access ● single WS / DAO / BOM / RESTful ● Domain specific nodes ● extensions via work item handlers ● Design process for reuse ● smallest unit of work20
  21. 21. Best Practices – Process Interaction ● Processes interact with your Enterprise ● Web Services, EJB, GUI, POJO, Exceptions, Bean Script, Rules... ● jBPM API & jBPM History DB & RESTful ● history / tasks / reporting ● single DAO ● single Web Service ● JBoss ESB + jBPM ● externalize rules calls in Decision Service (WS) Interaction Layer21 Human Tasks EJB / POJO ESB Web Services
  22. 22. Best Practices – Always good BPM practices... ● Simplify everything (KISS) ● apply OO to process design ● methods == sub-process + context in/out ● encapsulate == sub-process ● reuse == process repo (maven potential) ● unit testing == per node, sub-process, process ● exception handling (Exception Framework)22
  23. 23. Best Practices – Rule Architecture ● Partition your Knowledge Bases properly ● Subject matter ● Transaction / Service / Unit of Work ● Business Entity ● Avoid monolithic Knowledge Bases ● Avoid fine grained Knowledge Bases Knowledge Inference Knowledge Base Engine Session Tasks23
  24. 24. Best Practices – Rule Architecture ● Batch data loads ● Load 1000 facts and fire the rules faster than fire rules after each loaded fact ● Partition the data into multiple sessions ● Transaction / Service / Unit of work ● Creating a new session is cheap ● Cheaper than removing facts Knowledge Knowledge Inference Base Engine Session Tasks24
  25. 25. Best Practices – Rule Architecture ● 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 Inference Knowledge Base Engine Session Tasks25
  26. 26. JBoss BRMS – Best Practices in Rules Authoring26
  27. 27. Best Practices – Rules Authoring ● Dont try to micro-control rules execution ● Use the Conflict Resolution Strategies instead ● Salience ● Agenda groups ● Ruleflow / Processes ● Dynamic Enablement Knowledge Inference Knowledge Base Engine Session Tasks27
  28. 28. Best Practices – Rules Authoring ● Dont overload rules ● Each rule should describe one and only one scenario→action mapping ● The engine will optimize shared conditions ● The engine supports inference Knowledge Inference Knowledge Base Engine Session Tasks28
  29. 29. Best Bad Practices – Rules Authoring rule “1 – Teenagers and Elders get Discount” rule “1 – Teenagers and Elders get Discount” when when Person age is between 16 and 18 or Person age is greater or equal to 65 Person age is between 16 and 18 or Person age is greater or equal to 65 then then Assign 25% ticket discount Assign 25% ticket discount end end rule “2 – Elders can buy tickets in area A” rule “2 – Elders can buy tickets in area A” when when Person age is greater or equal to 65 Person age is greater or equal to 65 then then Allow sales of area A tickets Allow sales of area A tickets end end Rules are being overloaded with multiple concepts, increasing maintenance and testing costs.29
  30. 30. Best Practices – Rules Authoringrule “0.a – Teenagers are 16-18”rule “0.a – Teenagers are 16-18” rule “0.b – Elders are older than 65” rule “0.b – Elders are older than 65”whenwhen when when Person age is between 16 and 18 Person age is between 16 and 18 Person is older than 65 Person is older than 65thenthen then then Assert: the person is a Teenager Assert: the person is a Teenager Assert: the person is an Elder Assert: the person is an Elderendend end end rule “1 – Teenagers and Elders get discount” rule “1 – Teenagers and Elders get discount” rule “2 – Elders can buy tickets in area A” rule “2 – Elders can buy tickets in area A” when when when when Teenager or Elder Teenager or Elder Elder Elder then then then then Assign 25% ticket discount Assign 25% ticket discount Allow sales of area A tickets Allow sales of area A tickets end end end end30
  31. 31. Best Practices – Rules Authoring ● One calculation (accumulate) per rule ● Accumulates have O(n) performance ● Sequences of accumulates have O(nm) performance ● n = number of matching facts ● m = number of accumulates rule “Sum debits” rule “Sum debits” when whenrule “Sum debits and credits”rule “Sum debits and credits” accumulate( Debit( $d : amount ), accumulate( Debit( $d : amount ),whenwhen $debits: sum( $d ) ) $debits: sum( $d ) ) accumulate( Debit( $d : amount ), accumulate( Debit( $d : amount ), then ... then ... $debits: sum( $d ) ) $debits: sum( $d ) ) accumulate( Credit( $c : amount), accumulate( Credit( $c : amount), rule “Sum credits” rule “Sum credits” $credits: sum( $c ) ) $credits: sum( $c ) ) when whenthen ...then ... accumulate( Credit( $c : amount ), accumulate( Credit( $c : amount ), $credits: sum( $c ) ) $credits: sum( $c ) ) then ... then ...31
  32. 32. Best Practices – Rules Authoring ● Rules vs Queries Rules Queries Control Invoked by the engine Invoked by the application Parameters Dont support parameters Support parameters Results Execute actions Return results rule “Approve VIP customers” rule “Approve VIP customers” query “Get customers by type”( $type ) query “Get customers by type”( $type ) when when when when $c : Customer( type == “VIP” ) $c : Customer( type == “VIP” ) $c : Customer( type == $type ) $c : Customer( type == $type ) then then end end insert( new Approved( $c ) ); insert( new Approved( $c ) ); end end “Use the right tool for the right job!”32
  33. 33. Best Practices – Rules Authoring ● Declared Types ● Facts used only by the rules ● Facts that change frequently with the rules ● POJOs ● Facts shared by both rules and application ● No data copy – very efficient ● Easier to integrate, easier to test ● When in doubt, use POJOs “Use the right tool for the right job!”33
  34. 34. Add references● JBoss Enterprise BRMS Best Practices Guide http://www.redhat.com/promo/integrated_enterprise/brms-best-practices-form.html● JBoss Enterprise BRMS Best Practices, Edson Tirelli, http://www.redhat.com/summit/sessions/jboss.html● JBoss BRMS, http://www.redhat.com/products/jbossenterprisemiddleware/business-rules/● BRMS Best Practices Process Initialization Layer, http://howtojboss.com/2012/08/15/brms-best-practices-process-initialization-layer/34
  35. 35. Questions?

×