0
<ul>JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE  </ul><ul>Tihomir Surdilovic  [email_address]...
<ul>Agenda </ul><ul><li>Project (Drools) vs. Product (BRMS)
Drools Vision
Drools History
Drools at a glance </li></ul><ul><ul><li>Expert
Guvnor
JBPM5 </li></ul></ul><ul><li>Focus on Drools Fusion (CEP Extensions) </li></ul><ul><ul><li>Event Declaration and Semantics
Event Cloud, Streams and the Session Clock
Temporal Reasoning
Sliding Window Support
Streams Support
Memory Management </li></ul></ul><ul><li>Questions & Answers </li></ul>
<ul><li>Project vs. Product </li></ul>Repository Rules and Metadata JBoss Enterprise BRMS Platform JBoss Rules Rules Engin...
<ul><li>Project vs. Product Cont. </li></ul><ul><li>Stand-alone Framework
Innovation
Fast and Frequent Releases
Tested on developer environments
Suitable for development and prototype
No Patches – On to next big thing
Non SLA bound forum support </li></ul><ul><li>Fully Integrated Platform
Same Innovated Code + Stability
Stability – Includes usability, performance and security issues identified during productization
Certified for Multi-OS, Multi-DB
Best for Development and Production
5 Yr lifecycle – Includes patches, updates, backward compatibility
SLA based full support from dedicated support engineers
Open Source Assurance – legal protection </li></ul>derived
<ul>Jboss community and Enterprise  Changes </ul>Community / Enterprise Platform Delta BRMS Drools Enterprise Platforms - ...
<ul>Evolution of Jboss BRMS </ul>05/08   04/09   12/10   ?  <ul><li>Lightweight Business Rules Engine </li></ul><ul><li>Bu...
Authoring and Management App
Repository
EAP Certified
DBs, JVMs  </li></ul><ul><li>Business Rules Engine
Authoring and Management App
Choice of Repository
Integrated Container
CEP – Tech Preview
EAP, EWS, EWP, JVMs, Dbs and more
Performance </li></ul>Repository JBoss Enterprise BRMS Platform 5.0 JBoss Rules BRM Repository JBoss Enterprise BRMS Platf...
<ul>“ A  common platform  to  model  and  govern  the business  logic  of the enterprise.” </ul><ul>Drools Vision </ul>
<ul>Drools Vision Cont. </ul>Event Processes Semantic  Ontologies Workflows Rules Rules  Workflows Event Processes Semanti...
<ul>Drools History – Business Rule Engines </ul>1980s 2010s 1990s 2000s OPS5 ART Clips Jess Drools 2 JRules Drools 3 Drool...
<ul>Drools History </ul><ul><li>Drools 2 </li><ul><li>Rete like XML Scripting language </li></ul><li>Drools 3  </li><ul><l...
Iterative improves to JRules syntax with Clips functionality </li></ul><li>Drools 4 </li><ul><li>More declarative
Basic functional programming feature with “from”
Basic Rule Flow
Basic BRMS </li></ul><li>Drools 5 </li><ul><li>Improved functional programming with 'accumulate'
More Advanced Rule Flow integration
Complex Event Process </li><ul><li>Temporal Comparators
Sliding Time Windows </li></ul><li>Production ready BRMS (Guvnor) </li></ul></ul>
<ul>Drools History Cont. </ul><ul><li>Drools 5.1 </li><ul><li>Differential Diff (true modify) </li></ul><li>Drools 5.2 (th...
Multi-function accumulates
Prolog like derivation queries
Decision tables and rule templates (Guvnor)
Pure GWT (Guvnor) </li></ul></ul>
<ul>Sample Industries and Users </ul><ul><li>Investment </li><ul><li>Millennium Investment Group (MIG)   </li></ul><li>Log...
<ul>Drools at a glance - Declarative programming </ul><ul><li>Production Rule Systems PRD (forward chaining) </li><ul><li>...
when Alarm( status == “alert” )  then send( “warning” ) </li></ul><li>Logic Programming LP (backward chaining) </li><ul><l...
descendant( “mary”, “jane”) </li></ul><li>Functional Programming FP </li><ul><li>Map,Fold, Filter
avg([12, 16, 4, 6]) </li><ul><li>Returns single value 9.5 </li></ul><li>round([10.3, 4.7, 7.8] ) </li><ul><li>Returns List...
<ul>Drools Expert at a glance – Example A - SQL comparison example </ul>select * from  Account acc,  Cashflow cf, AccountP...
<ul>Drools Expert at a glance –  Rules as a view </ul>rule “increase balance for AccountPeriod  Credits” when ap : Account...
<ul>Drools Expert at a glance – Example A - Building and executing rules </ul>
<ul>Drools Expert at a glance – Example A Building and executing rules cont. </ul><ul><li>Building </li></ul><ul><li>Execu...
<ul>Drools Expert at a glance – Example B - Building and executing rules </ul>
<ul>Drools Expert at a glance – Example B cont. </ul><ul><li>No Fires </li></ul><ul><li>Add some  Fires </li></ul>
<ul>Drools Expert at a glance – Example B cont. </ul><ul><li>Fires are put out after a while </li></ul>
<ul>Drools Expert at a glance – Conditional Elements </ul>
<ul>Drools Expert at a glance – Accumulate CE </ul><ul><li>Bus Example </li></ul><ul><li>Accumulate general syntax </li></...
<ul>Drools Expert at a glance – Conditional Elements </ul><ul><li>From </li></ul>
<ul>Drools Expert at a glance – Timers and Calendars </ul><ul><li>Interval Timers </li></ul>Field Name   Mandatory?    All...
<ul>Drools Expert at a glance – Timers and Calendars </ul><ul><li>Calendars </li></ul><ul><li>Using Timers and Calendars t...
<ul>Drools Expert at a glance – Truth maintenance and Inference </ul><ul><li>Issuing Buss passes – typical rule implementa...
Encapsulate knowledge
Provide semantic abstractions for those encapsulation
Integrity robustness – truth maintenance </li></ul></ul><ul><li>These types of implementations are considered </li><ul><li...
Monolithic
Leaky
Upcoming SlideShare
Loading in...5
×

JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE

12,040

Published on

This session will introduce JBoss Drools - Popular business rules engine and JBoss Drools Fusion - a complex event processing engine which is an extension to business rules.

Business Rules bring in a new paradigm of programming which helps effectively separate business policies and application code. Enterprises can now build agile applications that quickly react to change in market conditions or internal operations.

Bringing in complex event processing into the same paradigm, these applications can now react to real time events in the business environment. Essentially with the use of Business Rules and CEP enterprise applications can be lot more agile than ever before.

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

No Downloads
Views
Total Views
12,040
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
547
Comments
0
Likes
15
Embeds 0
No embeds

No notes for slide

Transcript of "JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE"

  1. 1. <ul>JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE </ul><ul>Tihomir Surdilovic [email_address] JBoss, a Division of Red Hat </ul>
  2. 2. <ul>Agenda </ul><ul><li>Project (Drools) vs. Product (BRMS)
  3. 3. Drools Vision
  4. 4. Drools History
  5. 5. Drools at a glance </li></ul><ul><ul><li>Expert
  6. 6. Guvnor
  7. 7. JBPM5 </li></ul></ul><ul><li>Focus on Drools Fusion (CEP Extensions) </li></ul><ul><ul><li>Event Declaration and Semantics
  8. 8. Event Cloud, Streams and the Session Clock
  9. 9. Temporal Reasoning
  10. 10. Sliding Window Support
  11. 11. Streams Support
  12. 12. Memory Management </li></ul></ul><ul><li>Questions & Answers </li></ul>
  13. 13. <ul><li>Project vs. Product </li></ul>Repository Rules and Metadata JBoss Enterprise BRMS Platform JBoss Rules Rules Engine/ Execution Rules Development & Management CEP Complex Events Jboss EWP
  14. 14. <ul><li>Project vs. Product Cont. </li></ul><ul><li>Stand-alone Framework
  15. 15. Innovation
  16. 16. Fast and Frequent Releases
  17. 17. Tested on developer environments
  18. 18. Suitable for development and prototype
  19. 19. No Patches – On to next big thing
  20. 20. Non SLA bound forum support </li></ul><ul><li>Fully Integrated Platform
  21. 21. Same Innovated Code + Stability
  22. 22. Stability – Includes usability, performance and security issues identified during productization
  23. 23. Certified for Multi-OS, Multi-DB
  24. 24. Best for Development and Production
  25. 25. 5 Yr lifecycle – Includes patches, updates, backward compatibility
  26. 26. SLA based full support from dedicated support engineers
  27. 27. Open Source Assurance – legal protection </li></ul>derived
  28. 28. <ul>Jboss community and Enterprise Changes </ul>Community / Enterprise Platform Delta BRMS Drools Enterprise Platforms - Performance, Scalability, Security and Quality improves over time without compromising long-term compatibility. 08/09 12/10 03/11 05/11 Over 150+ defect fixes & 35+ OS/JVM/DB certifications (& counting) between Drools Community 5.1 & JBoss BRMS 5.1.x
  29. 29. <ul>Evolution of Jboss BRMS </ul>05/08 04/09 12/10 ? <ul><li>Lightweight Business Rules Engine </li></ul><ul><li>Business Rules Engine
  30. 30. Authoring and Management App
  31. 31. Repository
  32. 32. EAP Certified
  33. 33. DBs, JVMs </li></ul><ul><li>Business Rules Engine
  34. 34. Authoring and Management App
  35. 35. Choice of Repository
  36. 36. Integrated Container
  37. 37. CEP – Tech Preview
  38. 38. EAP, EWS, EWP, JVMs, Dbs and more
  39. 39. Performance </li></ul>Repository JBoss Enterprise BRMS Platform 5.0 JBoss Rules BRM Repository JBoss Enterprise BRMS Platform 5.1 JBoss Rules BRM CEP Jboss EWP
  40. 40. <ul>“ A common platform to model and govern the business logic of the enterprise.” </ul><ul>Drools Vision </ul>
  41. 41. <ul>Drools Vision Cont. </ul>Event Processes Semantic Ontologies Workflows Rules Rules Workflows Event Processes Semantic Ontologies
  42. 42. <ul>Drools History – Business Rule Engines </ul>1980s 2010s 1990s 2000s OPS5 ART Clips Jess Drools 2 JRules Drools 3 Drools 4 Drools 5
  43. 43. <ul>Drools History </ul><ul><li>Drools 2 </li><ul><li>Rete like XML Scripting language </li></ul><li>Drools 3 </li><ul><li>Based on Clips functionality
  44. 44. Iterative improves to JRules syntax with Clips functionality </li></ul><li>Drools 4 </li><ul><li>More declarative
  45. 45. Basic functional programming feature with “from”
  46. 46. Basic Rule Flow
  47. 47. Basic BRMS </li></ul><li>Drools 5 </li><ul><li>Improved functional programming with 'accumulate'
  48. 48. More Advanced Rule Flow integration
  49. 49. Complex Event Process </li><ul><li>Temporal Comparators
  50. 50. Sliding Time Windows </li></ul><li>Production ready BRMS (Guvnor) </li></ul></ul>
  51. 51. <ul>Drools History Cont. </ul><ul><li>Drools 5.1 </li><ul><li>Differential Diff (true modify) </li></ul><li>Drools 5.2 (this month, 5.2.0.CR1 available for download) </li><ul><li>Freeform expressions between patterns
  52. 52. Multi-function accumulates
  53. 53. Prolog like derivation queries
  54. 54. Decision tables and rule templates (Guvnor)
  55. 55. Pure GWT (Guvnor) </li></ul></ul>
  56. 56. <ul>Sample Industries and Users </ul><ul><li>Investment </li><ul><li>Millennium Investment Group (MIG) </li></ul><li>Logistics </li><ul><li>Fedex </li></ul><li>Airline </li><ul><li>Sabre </li></ul><li>Mortgage </li><ul><li>Franklin American </li></ul><li>Healthcare </li><ul><li>OSDE </li></ul></ul>
  57. 57. <ul>Drools at a glance - Declarative programming </ul><ul><li>Production Rule Systems PRD (forward chaining) </li><ul><li>Reactive
  58. 58. when Alarm( status == “alert” ) then send( “warning” ) </li></ul><li>Logic Programming LP (backward chaining) </li><ul><li>Query
  59. 59. descendant( “mary”, “jane”) </li></ul><li>Functional Programming FP </li><ul><li>Map,Fold, Filter
  60. 60. avg([12, 16, 4, 6]) </li><ul><li>Returns single value 9.5 </li></ul><li>round([10.3, 4.7, 7.8] ) </li><ul><li>Returns List [10, 5, 8] </li></ul></ul><li>Description Logic (model concepts, roles, and individuals) </li><ul><li>Person Has Name and lives at Address </li></ul></ul>
  61. 61. <ul>Drools Expert at a glance – Example A - SQL comparison example </ul>select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end trigger : acc.balance += cf.amount rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance += $amount; end
  62. 62. <ul>Drools Expert at a glance – Rules as a view </ul>rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance += $amount; end rule “decrease balance for AccountPeriod Debits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == DEBIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance -= $amount; end
  63. 63. <ul>Drools Expert at a glance – Example A - Building and executing rules </ul>
  64. 64. <ul>Drools Expert at a glance – Example A Building and executing rules cont. </ul><ul><li>Building </li></ul><ul><li>Executing </li></ul>
  65. 65. <ul>Drools Expert at a glance – Example B - Building and executing rules </ul>
  66. 66. <ul>Drools Expert at a glance – Example B cont. </ul><ul><li>No Fires </li></ul><ul><li>Add some Fires </li></ul>
  67. 67. <ul>Drools Expert at a glance – Example B cont. </ul><ul><li>Fires are put out after a while </li></ul>
  68. 68. <ul>Drools Expert at a glance – Conditional Elements </ul>
  69. 69. <ul>Drools Expert at a glance – Accumulate CE </ul><ul><li>Bus Example </li></ul><ul><li>Accumulate general syntax </li></ul><ul><li>Bus Example Revisited (no accumulate functions) </li></ul>
  70. 70. <ul>Drools Expert at a glance – Conditional Elements </ul><ul><li>From </li></ul>
  71. 71. <ul>Drools Expert at a glance – Timers and Calendars </ul><ul><li>Interval Timers </li></ul>Field Name Mandatory? Allowed Values Allowed Special Characters Seconds YES 0-59 , - * / Minutes YES 0-59 , - * / Hours YES 0-23 , - * / Day of month YES 1-31 , - * ? / L W Month YES 1-12 or JAN-DEC , - * / Day of week YES 1-7 or SUN-SAT , - * ? / L # Year NO empty, 1970-2099 , - * / <ul><li>Cron-based Timers </li></ul>
  72. 72. <ul>Drools Expert at a glance – Timers and Calendars </ul><ul><li>Calendars </li></ul><ul><li>Using Timers and Calendars together </li></ul>Execute now and after 1 hour duration on week days Execute now and after 4 hour duration on weekend days
  73. 73. <ul>Drools Expert at a glance – Truth maintenance and Inference </ul><ul><li>Issuing Buss passes – typical rule implementation </li></ul><ul><li>Good practice to do: </li><ul><li>De-couple knowledge responsibilities
  74. 74. Encapsulate knowledge
  75. 75. Provide semantic abstractions for those encapsulation
  76. 76. Integrity robustness – truth maintenance </li></ul></ul><ul><li>These types of implementations are considered </li><ul><li>Bad
  77. 77. Monolithic
  78. 78. Leaky
  79. 79. Brittle integrity - manual maintenance </li></ul></ul>Couples the logic What happens when the Child becomes 16?
  80. 80. <ul>Drools Expert at a glance – Truth maintenance and Inference cont. </ul><ul><li>De-coupling knowledge responsibilities </li></ul>De-couples the logic Maintains the truth by automatically retracting. <ul>Rule “logically” inserts an object. When the rule is no longer true, the object is retracted. </ul>The truth maintenance cascades
  81. 81. <ul>Drools Expert at a glance – Truth maintenance and Inference cont. </ul><ul><li>Notification upon automatic fact retraction </li></ul><ul><li>Executing </li></ul>The truth maintenance cascades
  82. 82. <ul>Drools Expert at a glance – Roadmap </ul><ul><li>Improved backward chaining (open queries)
  83. 83. Optimistic backward chaining.
  84. 84. Business Semantics (ontologies)
  85. 85. Simulation Testing
  86. 86. High Availability
  87. 87. Distributed (Grid) platform
  88. 88. Runtime Management </li></ul><ul><li>BAM (Business Activity Monitoring) </li></ul>
  89. 89. <ul>Drools Guvnor at a glance </ul><ul><li>Technology </li><ul><li>JCR 2.0 (JSR-170) backend
  90. 90. Seam 2 + GWT frontend
  91. 91. WebDav
  92. 92. Eclipse synchronisation plugin
  93. 93. Role based security </li></ul><li>Authoring </li><ul><li>Decision Tables
  94. 94. Guided Editor </li></ul><li>QA </li><ul><li>Scenario Testing + Rule Verification </li></ul></ul>
  95. 95. <ul>Drools Guvnor at a glance – Business asset storage </ul>
  96. 96. <ul>Drools Guvnor at a glance – Guided Editor </ul>
  97. 97. <ul>Drools Guvnor at a glance – Decision Tables </ul>
  98. 98. <ul>Drools Guvnor at a glance – Scenario Testing </ul>
  99. 99. <ul>Drools Guvnor at a glance – BPMN2 processes </ul>
  100. 100. <ul>Drools Guvnor at a glance – Compiling and exposing rule packages </ul>
  101. 101. <ul>jBPM5 at a glance – What is BPM? </ul>Business Process Management A business process is a process that describes the order in which a series of steps need to be executed, using a flow chart.
  102. 102. <ul>jBPM5 at a glance – Why BPM? </ul><ul><li>Visibility
  103. 103. Monitoring
  104. 104. Higher-level </li></ul><ul><li>Continuous improvement
  105. 105. Speed of development
  106. 106. Increased agility </li></ul>
  107. 107. <ul>jBPM5 at a glance – Key Characteristics </ul><ul><li>Open-source business process management project offering: </li></ul><ul><ul><li>generic process engine supporting native BPMN 2.0 execution
  108. 108. targeting developers and business users
  109. 109. collaboration, management and monitoring using web-based consoles
  110. 110. powerful rules and event integration </li></ul></ul><ul><li>Core engine is a workflow engine in pure Java </li></ul><ul><ul><li>state transitions
  111. 111. lightweight
  112. 112. embeddable
  113. 113. generic, extensible </li></ul></ul>Core Engine
  114. 114. <ul>jBPM5 at a glance – Core Engine </ul>// (1) Create knowledge base and add process definition KnowledgeBuilder kbuilder = ... kbuilder.add( ..., &quot;sample.bpmn&quot;, ResourceType.BPMN2); KnowledgeBase kbase = kbuilder.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); // (2) Create new stateful knowledge session StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); // (3) Start a new process instance ksession.startProcess(“com.sample.bpmn.hello”); Knowledge Base Stateful Knowledge Session Process Definition Process Instance
  115. 115. <ul>jBPM5 at a glance – BPMN 2.0 </ul><ul><li>OMG specification </li><ul><li>Model
  116. 116. Notation
  117. 117. Execution semantics </li></ul><li>Understandable by all business users
  118. 118. Process, collaboration, choreography
  119. 119. Extensible </li></ul>< definitions ... > < process id=&quot;com.sample.bpmn.hello&quot; name=&quot;Hello World&quot; > < startEvent id=&quot;_1&quot; name=&quot;StartProcess&quot; /> < sequenceFlow sourceRef=&quot;_1&quot; targetRef=&quot;_2&quot; /> < scriptTask id=&quot;_2&quot; name=&quot;Hello&quot; > < script >System.out.println(&quot;Hello World&quot;);</ script > </ scriptTask > < sequenceFlow sourceRef=&quot;_2&quot; targetRef=&quot;_3&quot; /> < endEvent id=&quot;_3&quot; name=&quot;EndProcess&quot; /> </ process > </ definitions > Core Engine BPMN 2.0 XML
  120. 120. <ul>jBPM5 at a glance – Persistence and Transactions </ul><ul><li>Persistence (JPA, pluggable) </li><ul><li>Runtime persistence
  121. 121. History logging
  122. 122. Services </li></ul><li>Transactions (JTA, pluggable) </li><ul><li>Command-scoped
  123. 123. User-defined </li></ul></ul>Core Engine BPMN 2.0 XML Persistence Trans- actions JPA JTA
  124. 124. <ul>jBPM5 at a glance – Console </ul><ul><li>Web-based management
  125. 125. Business user
  126. 126. Features </li></ul><ul><ul><li>Process instance management
  127. 127. User task lists / forms
  128. 128. Reporting </li></ul></ul>Core Engine BPMN 2.0 XML Persistence Trans- actions Events History Log Management Console BAM
  129. 129. <ul>jBPM5 at a glance – Console </ul><ul><li>Domain-specific Processes: </li><ul><li>Extend palette with
  130. 130. domain-specific, declarative
  131. 131. service nodes </li></ul></ul><ul><ul><ul><li>define input / output parameters
  132. 132. runtime binding </li></ul></ul></ul><ul><li>User task
  133. 133. Human task service (WS-HT) </li></ul><ul><ul><li>Task lists
  134. 134. Task life cycle </li></ul></ul><ul><li>Task clients </li></ul><ul><ul><li>Task forms </li></ul></ul>Core Engine BPMN 2.0 XML Persistence Trans- actions Events Integration Domain-specific Processes Human Task Service ESB
  135. 135. <ul>jBPM5 at a glance – Roadmap </ul><ul><li>jBPM 5.0: February 2011
  136. 136. jBPM 5.1: NOW ... </li><ul><li>Improve Oryx BPMN2 designer to support full round-tripping
  137. 137. New Eclipse BPMN2 editor
  138. 138. Lots of small feature improvements and bug fixes </li></ul><li>jBPM 5.2 – jBPM 6.x </li><ul><li>Simulation / testing / replay
  139. 139. Flexible, adaptive, goal-oriented processes
  140. 140. Integrated “no-code” tooling (form builder, etc.) </li></ul></ul>
  141. 141. <ul>Focus on Drools Fusion (CEP) </ul><ul><li>Brief introduction on CEP and Terminology
  142. 142. Drools Vision
  143. 143. Drools Fusion: Complex Event Processing extensions </li></ul><ul><ul><li>Event Declaration and Semantics
  144. 144. Event Cloud, Streams and the Session Clock
  145. 145. Temporal Reasoning
  146. 146. Sliding Window Support
  147. 147. Streams Support
  148. 148. Memory Management </li></ul></ul>
  149. 149. <ul>Drools Fusion – What is an Event? </ul><ul><ul><li>“ An event is an observable occurrence .”
  150. 150. “ An event in the Unified Modelling Language is a notable occurrence at a particular point in time .”
  151. 151. http://www.wikipedia.org
  152. 152. “ Anything that happens , or is contemplated as happening .”
  153. 153. “ An object that represents, encodes or records an event , generally for the purpose of computer processing ”
  154. 154. http://complexevents.com </li></ul></ul><ul><ul><li>For the scope of this presentation:
  155. 155. “ An event is a significant change of state at a particular point in time ” </li></ul></ul>
  156. 156. <ul>Drools Fusion – What is a Complex Event? </ul><ul><ul><li>“ Complex Event , is an abstraction of other events called its members.” </li></ul></ul><ul><li>Examples : </li></ul><ul><ul><li>The 1929 stock market crash – an abstraction denoting many thousands of member events, including individual stock trades)
  157. 157. The 2004 Indonesian Tsunami – an abstraction of many natural events
  158. 158. A completed stock purchase -an abstraction of the events in a transaction to purchase the stock
  159. 159. A successful on-line shopping cart checkout – an abstraction of shopping cart events on an on-line website </li></ul></ul><ul><ul><li>Source: http://complexevents.com </li></ul></ul>
  160. 160. <ul>Drools Fusion – What is Complex Event Processing (CEP)? </ul><ul><ul><li>“ Complex Event Processing , or CEP, is primarily an event processing concept that deals with the task of processing multiple events with the goal of identifying the meaningful events within the event cloud.
  161. 161. CEP employs techniques such as detection of complex patterns of many events, event correlation and abstraction , event hierarchies, and relationships between events such as causality, membership, and timing, and event-driven processes.”
  162. 162. -- wikipedia </li></ul></ul>
  163. 163. <ul>Drools Fusion – CEP Scenarios </ul><ul><li>Examples: </li></ul><ul><ul><li>Emergency Response Systems
  164. 164. Credit Card Fraud Detection
  165. 165. Logistics Real-Time Awareness solution
  166. 166. Neonatal ICU: infant vital signs monitoring </li></ul></ul><ul><li>A few characteristics of common CEP scenarios: </li></ul><ul><ul><li>Huge volume of events, but only a few of real interest </li></ul></ul><ul><ul><li>Usually events are immutable
  167. 167. Usually queries/rules have to run in reactive mode
  168. 168. Strong temporal relationships between events </li></ul></ul><ul><ul><li>Individual events are usually not important </li></ul></ul><ul><ul><li>The composition and aggregation of events is important </li></ul></ul>
  169. 169. <ul>Drools Fusion – CEP vs. ESP </ul><ul><ul><li>Complex Event Processing , or CEP, and Event Stream Processing , or ESP, are two technologies that were born separate, but converged . </li></ul></ul><ul><li>An oversimplification : In their origins... </li></ul><ul><ul><li>Event Stream Processing focused on the ability to process high volume streams of events.
  170. 170. Complex Event Processing focused on defining, detecting and processing the relationships among events. </li></ul></ul><ul><ul><li>For the scope of this presentation:
  171. 171. “ CEP is used as a common term meaning both CEP and ESP .” </li></ul></ul>
  172. 172. <ul>Drools Fusion – EDA </ul><ul>“ Event Driven Architecture (EDA) is a software architecture pattern promoting the production , detection , consumption of, and reaction to events. An event can be defined as &quot;a significant change in state&quot;[1]. For example, when a consumer purchases a car, the car's state changes from &quot;for sale&quot; to &quot;sold&quot;. A car dealer's system architecture may treat this state change as an event to be produced, published, detected and consumed by various applications within the architecture.” http://en.wikipedia.org/wiki/Event_Driven_Architecture </ul><ul>CEP is a component of the EDA </ul>
  173. 173. <ul>Drools Fusion – EDA vs SOA </ul><ul><li>EDA is **not** SOA 2.0
  174. 174. Complementary architectures
  175. 175. Metaphor </li></ul><ul><ul><li>In our body : </li></ul></ul><ul><ul><ul><li>SOA is used to build our muscles and organs (what's needed to DO things)
  176. 176. EDA is used to build our sensory system (what's needed to REACT TO things) </li></ul></ul></ul>
  177. 177. <ul>Drools Fusion – CEP Characteristics </ul><ul><li>A few characteristics of common CEP scenarios: </li></ul><ul><ul><li>Huge volume of events, but only a few of real interest </li></ul></ul><ul><ul><li>Usually events are immutable
  178. 178. Usually queries/rules have to run in reactive mode
  179. 179. Strong temporal relationships between events </li></ul></ul><ul><ul><li>Individual events are usually not important </li></ul></ul><ul><ul><li>The composition and aggregation of events is important </li></ul></ul>
  180. 180. <ul>Drools Fusion – Enables... </ul><ul><li>Event Detection: </li></ul><ul><ul><li>From an event cloud or set of streams, select all the meaningful events, and only them. </li></ul></ul><ul><li>[Temporal] Event Correlation: </li></ul><ul><ul><li>Ability to correlate events and facts declaring both temporal and non-temporal constraints between them.
  181. 181. Ability to reason over event aggregation </li></ul></ul><ul><li>Event Abstraction: </li></ul><ul><ul><li>Ability to compose complex events from atomic events AND reason over them </li></ul></ul>
  182. 182. <ul>Drools Fusion – Features </ul><ul><li>Features: </li></ul><ul><ul><li>Event Semantics as First Class Citizens
  183. 183. Allow Detection, Correlation and Composition
  184. 184. Temporal Constraints
  185. 185. Session Clock
  186. 186. Stream Processing
  187. 187. Sliding Windows
  188. 188. CEP volumes (scalability)
  189. 189. (Re)Active Rules
  190. 190. Data Loaders for Input </li></ul></ul>
  191. 191. <ul>Drools Fusion – Demo </ul><ul><li>Twitter Stream CEP Demo: </li></ul><ul><ul><li>Listen to the Twitter Stream API </li><ul><li>Twitter4J API
  192. 192. Listens to a random sample of tweets </li></ul><li>Detects patterns and reacts </li><ul><li>Drools Fusion </li></ul><li>Simple one process (multi-thread) demo </li><ul><li>Focus on specific features </li></ul></ul></ul>
  193. 193. <ul>Drools Fusion – Event Declaration and Semantics </ul><ul><li>Event semantics: </li></ul><ul><ul><li>Point-in-time and Interval </li></ul></ul><ul><li>An event is a fact with a few special characteristics: </li></ul><ul><ul><li>Usually immutable , but not enforced
  194. 194. Strong temporal relationships </li></ul></ul><ul><ul><li>Lifecycle may be managed </li></ul></ul><ul><ul><li>Allow use of sliding windows </li></ul></ul><ul><li>“ All events are facts , but not all facts are events.”
  195. 195. Demo twitter rules part 1, 2, 3) </li></ul><ul>// declaring existing class import some.package.VoiceCall declare VoiceCall @role ( event ) @timestamp ( calltime ) @duration ( duration ) end // generating an event class declare StockTick @role ( event ) symbol : String price : double end </ul>
  196. 196. <ul>Drools Fusion – Temporal Reasoning </ul><ul><li>Semantics for: </li></ul><ul><ul><li>time: discrete
  197. 197. events: point-in-time and interval </li></ul></ul><ul><li>Ability to express temporal relationships: </li></ul><ul><ul><li>Allen’s 13 temporal operators </li></ul></ul><ul><li>James F. Allen defined the 13 possible temporal relations between two events.
  198. 198. Eiko Yoneki and Jean Bacon defined a unified semantics for event correlation over time and space. </li></ul>
  199. 199. <ul>Drools Fusion – Temporal Relationships </ul><ul>rule “Shipment not picked up in time” when Shipment ( $pickupTime : scheduledPickupTime ) not ShipmentPickup ( this before $pickupTime ) then // shipment not picked up... Action required. end </ul><ul>Temporal Relationship </ul>
  200. 200. <ul>Drools Fusion – Allen’s 13 Temporal Operators </ul><ul>Point-Point </ul><ul>Point-Interval </ul><ul>Interval-Interval </ul><ul>A before B </ul><ul>A meets B </ul><ul>A overlaps B </ul><ul>A finishes B </ul><ul>A includes B </ul><ul>A starts B </ul><ul>A coincides B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul>
  201. 201. <ul>Drools Fusion – Allen’s 13 Temporal Operators </ul><ul>Point-Point </ul><ul>Point-Interval </ul><ul>Interval-Interval </ul><ul>A after B </ul><ul>A metBy B </ul><ul>A overlapedBy B </ul><ul>A finishedBy B </ul><ul>A during B </ul><ul>A finishes B </ul><ul><li>Demo twitter rules part 4 </li></ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul><ul>A </ul><ul>B </ul>
  202. 202. <ul>Drools Fusion – Streams : Simple Example Scenario </ul>
  203. 203. <ul>Drools Fusion – Stream Support (entry-points) </ul><ul><li>A scoping abstraction for stream support </li></ul><ul><ul><li>Rule compiler gather all entry-point declarations and expose them through the session API
  204. 204. Engine manages all the scoping and synchronization behind the scenes. </li></ul></ul><ul>rule “Stock Trade Correlation” <li>when
  205. 205. $c : Customer( type == “VIP” )
  206. 206. BuyOrderEvent( customer == $c , $id : id ) from entry-point “Home Broker Stream”
  207. 207. BuyAckEvent( sourceEvent == $id ) from entry-point “Stock Trader Stream”
  208. 208. then
  209. 209. // take some action
  210. 210. end </li></ul>
  211. 211. <ul><li>No notion of “flow of time” : the engine sees all facts without regard to time
  212. 212. No attached Session Clock
  213. 213. No requirements on event ordering
  214. 214. No automatic event lifecycle management
  215. 215. No sliding window support </li></ul><ul><li>Notion of “flow of time” : concept of “now”
  216. 216. Session Clock has an active role synchronizing the reasoning
  217. 217. Event Streams must be ordered
  218. 218. Automatic event lifecycle management
  219. 219. Sliding window support
  220. 220. Automatic rule delaying on absence of facts </li></ul><ul>Drools Fusion – Cloud Mode, Stream Mode, Session Clock </ul><ul>CLOUD </ul><ul>STREAM </ul>
  221. 221. <ul>Drools Fusion – Reference Clock </ul><ul><li>Reference clock defines the flow of time </li></ul><ul><li>Named Session Clock </li></ul><ul><ul><li>is assigned to each session created </li></ul></ul><ul><li>Synchronizes time sensitive operations </li></ul><ul><ul><li>duration rules
  222. 222. event streams
  223. 223. process timers
  224. 224. sliding windows </li></ul></ul>
  225. 225. <ul>Drools Fusion – Session Clock </ul><ul><li>Uses the strategy pattern and multiple implementations: </li></ul><ul><ul><li>Real-time operation
  226. 226. Tests
  227. 227. Simulations
  228. 228. etc </li></ul></ul>
  229. 229. <ul>Drools Fusion – Session Clock </ul><ul><li>Selecting the session clock: </li></ul><ul><ul><li>API: </li></ul></ul><ul><ul><ul><li>KnowledgeSessionConfiguration conf = ...
  230. 230. conf.setOption( ClockTypeOption.get( “realtime” ) ); </li></ul></ul></ul><ul><ul><li>System Property or Configuration File: </li></ul></ul><ul>drools.clockType = pseudo </ul>
  231. 231. <ul>Drools Fusion – Sliding Window Support </ul><ul><li>Allows reasoning over a moving window of “interest” </li></ul><ul><ul><li>Time
  232. 232. Length </li></ul></ul>Sliding window 1 Sliding window 2
  233. 233. <ul>Drools Fusion – Sliding Window Support </ul><ul><li>Allows reasoning over a moving window of “interest” </li></ul><ul><ul><li>Time
  234. 234. Length </li></ul></ul>Sliding window 1 Sliding window 2 Joined window
  235. 235. <ul>Drools Fusion – Sliding Window Support </ul><ul><li>Allows reasoning over a moving window of “interest” </li></ul><ul><ul><li>Time
  236. 236. Length </li></ul></ul><ul><li>Demo twitter rules part 5 </li></ul><ul>rule “Average Order Value over 12 hours” when $c : Customer() $a : Number() from accumulate ( BuyOrder( customer == $c , $p : price ) <li>over window:time ( 12h ),
  237. 237. average ( $p ) )
  238. 238. then
  239. 239. // do something
  240. 240. end </li></ul>
  241. 241. <ul>Drools Fusion – Delaying Rules </ul><ul><li>Negative patterns may require rule firings to be delayed. </li></ul><ul>rule “Order timeout” when $bse : BuyShares ( $id : id ) not BuySharesAck( id == $id , this after[0s,30s] $bse ) then // Buy order was not acknowledged. Cancel operation // by timeout. end </ul><ul>Forces the rule to wait for 30 seconds before firing, because the acknowledgement may arrive at any time! </ul>
  242. 242. <ul>Drools Fusion – Temporal Dimension </ul><ul><li>Requires the support to the temporal dimension </li></ul><ul><ul><li>A rule/query might match in a given point in time, and not match in the subsequent point in time </li></ul></ul><ul><li>That is the single most difficult requirement to support in a way that the engine: </li></ul><ul><ul><li>stays deterministic
  243. 243. stays a high-performance engine </li></ul></ul><ul><li>Achieved mostly by compile time optimizations that enable: </li></ul><ul><ul><li>constraint tightening
  244. 244. match space narrowing
  245. 245. memory management </li></ul></ul>
  246. 246. <ul>Drools Fusion – Temporal Dimension Support </ul><ul><li>CEP scenarios are stateful by nature.
  247. 247. Events usually are only interesting during a short period of time .
  248. 248. Hard for applications to know when events are not necessary anymore </li></ul><ul><ul><li>Temporal constraints and sliding windows describe such “ window of interest ” </li></ul></ul>
  249. 249. <ul>Drools Fusion – Simple Example Rule </ul><ul>rule “Bag was lost” when $b : BagScannedEvent() from entry-point “check-in” not BagScannedEvent( id == $b.id , this after[0s,5m] $b ) <li>from entry-point “pre-load”
  250. 250. then
  251. 251. // Bag was lost, do something
  252. 252. end </li></ul>Easy to “see” that the only temporal relationship between the events defines a 5 minutes interest window.
  253. 253. <ul>Drools Fusion – Abstract Example Rule </ul><ul>rule “Abstract event relationship example” when $a : A() $b : B( this after[-2, 2] $a ) $c : C( this after[-3, 4] $a ) $d : D( this after[ 1, 2] $b, this after[2,3] $c ) not E( this after[ 1,10] $d ) then // Bag was lost, do something end </ul>How about now? What is the temporal relationship between A and E?
  254. 254. <ul>Drools Fusion – Temporal Dependency Matrix </ul><ul>A </ul><ul>B </ul><ul>C </ul><ul>D </ul><ul>E </ul><ul>A </ul><ul>[ 0, 0 ] </ul><ul>[ -2, 2 ] </ul><ul>[ -3, 2 ] </ul><ul>[ -1, 4 ] </ul><ul>[ 0, 14 ] </ul><ul>B </ul><ul>[ -2, 2 ] </ul><ul>[ 0, 0 ] </ul><ul>[ -2, 0 ] </ul><ul>[ 1, 2 ] </ul><ul>[ 2, 12 ] </ul><ul>C </ul><ul>[ -2, 3 ] </ul><ul>[ 0, 2 ] </ul><ul>[ 0, 0 ] </ul><ul>[ 2, 3 ] </ul><ul>[ 3, 13 ] </ul><ul>D </ul><ul>[ -4, 1 ] </ul><ul>[ -2, -1 ] </ul><ul>[ -3, -2 ] </ul><ul>[ 0, 0 ] </ul><ul>[ 1, 10 ] </ul><ul>E </ul><ul>[ -14, 0 ] </ul><ul>[ -12, -2 ] </ul><ul>[ -13, -3 ] </ul><ul>[-10,-1 ] </ul><ul>[ 0, 0 ] </ul>Constraint tightening <ul><li>Demo twitter rules part 6 </li></ul><ul>[-2,2] </ul><ul>[-3,4] </ul><ul>[2,3] </ul><ul>[1,2] </ul><ul>[1,10] </ul><ul>A </ul><ul>D </ul><ul>B </ul><ul>E </ul><ul>C </ul>
  255. 255. <ul>Q&A </ul><ul><li>Drools project site: </li></ul><ul><ul><li>http://www.drools.org ( http://www.jboss.org/drools/ ) </li></ul></ul><ul><li>Documentation: </li></ul><ul><ul><li>http://www.jboss.org/drools/documentation.html </li></ul></ul><ul><li>Tihomir Surdilovic – tsurdilo @redhat.com </li></ul>
  1. A particular slide catching your eye?

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

×