Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011

Geoffrey De Smet
Geoffrey De SmetSoftware developer at Red Hat
Applying Complex Event Processing
        with Drools Fusion
                                Edson Tirelli
                        etirelli@redhat.com
                              Lead CEP Engineer
                      JBoss, a Division of Red Hat
Agenda


o   Brief introduction on CEP and Terminology
o   Drools Vision
o   Drools Fusion: Complex Event Processing extensions
     o Event Declaration and Semantics

     o Event Cloud, Streams and the Session Clock

     o Temporal Reasoning

     o Sliding Window Support

     o Streams Support

     o Memory Management

o   Questions & Answers
Terminology: Event


“An event is an observable occurrence.”
“An event in the Unified Modeling Language is a
  notable occurrence at a particular point in time.”
                               http://www.wikipedia.org


“Anything that happens, or is contemplated as
  happening.”
“An object that represents, encodes or records an
  event, generally for the purpose of computer
  processing”
                         http://complexevents.com
Terminology: Event


For the scope of this presentation:



 “An event is a significant change of
   state at a particular point in time”
Terminology: Complex Event


    “Complex Event, is an abstraction of other events
      called its members.”

o   Examples:
    o   The 1929 stock market crash – an abstraction denoting many
        thousands of member events, including individual stock trades)
    o   The 2004 Indonesian Tsunami – an abstraction of many natural
        events
    o   A completed stock purchase -an abstraction of the events in a
        transaction to purchase the stock
    o   A successful on-line shopping cart checkout – an abstraction of
        shopping cart events on an on-line website



                        Source: http://complexevents.com
Terminology: CEP


“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.

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.”
                                        -- wikipedia
Terminology: CEP


o   Examples:
    o   Emergency Response Systems
    o   Credit Card Fraud Detection
    o   Logistics Real-Time Awareness solution
    o   Neonatal ICU: infant vital signs monitoring
Terminology: CEP vs ESP


    Complex Event Processing, or CEP, and Event
     Stream Processing, or ESP, are two
     technologies that were born separate, but
     converged.

●
    An oversimplification: In their origins...
      Event Stream Processing focused on the ability to

       process high volume streams of events.
      Complex Event Processing focused on defining,

       detecting and processing the relationships among
       events.
Terminology: CEP and ESP


For the scope of this presentation:



    “CEP is used as a common term
      meaning both CEP and ESP.”
Terminology: EDA


“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 "a
  significant change in state"[1]. For example, when a
  consumer purchases a car, the car's state changes from "for
  sale" to "sold". 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
EDA vs CEP

                    CEP is a component of the EDA




Source: http://elementallinks.typepad.com/.shared/image.html?/photos/uncategorized/simple_event_flow.gif
EDA vs SOA


o   EDA is **not** SOA 2.0
o   Complementary architectures
o   Metaphor
     o In our body:

         o SOA is used to build our muscles and organs

         o EDA is used to build our sensory system
EDA vs SOA




Source: http://soa-eda.blogspot.com/2006/11/how-eda-extends-soa-and-why-it-is.html
Complex Event Processing


o   A few characteristics of common CEP scenarios:
     o Huge volume of events, but only a few of real interest

     o Usually events are immutable

     o Usually queries/rules have to run in reactive mode

     o Strong temporal relationships between events

     o Individual events are usually not important

     o The composition and aggregation of events is important
Drools Vision




“A common platform to model and govern the
     business logic of the enterprise.”
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
Drools Fusion: Enables…


•   Event Detection:
     • From an event cloud or set of streams, select all the

       meaningful events, and only them.
•   [Temporal] Event Correlation:
     • Ability to correlate events and facts declaring both

       temporal and non-temporal constraints between them.
     • Ability to reason over event aggregation

•   Event Abstraction:
     • Ability to compose complex events from atomic events

       AND reason over them
Drools Fusion


o   Features:
     o Event Semantics as First Class Citizens

     o Allow Detection, Correlation and Composition

     o Temporal Constraints

     o Session Clock

     o Stream Processing

     o Sliding Windows

     o CEP volumes (scalability)

     o (Re)Active Rules

     o Data Loaders for Input
Demo


o   Twitter Stream CEP Demo:
     o Listen to the Twitter Stream API

         Twitter4J API

         Listens to a random sample of tweets

     o Detects patterns and reacts

         Drools Fusion

     o Simple one process (multi-thread) demo

         Focus on specific features
Event Declaration and Semantics


// declaring existing class
import some.package.VoiceCall
                                o   Event semantics:
declare VoiceCall                    o Point-in-time and Interval
  @role( event )
  @timestamp( calltime )
  @duration( duration )
end
                                o   An event is a fact with a few
                                    special characteristics:
// generating an event class         o Usually immutable, but not
declare StockTick
  @role( event )                       enforced
                                     o Strong temporal relationships
  symbol : String
  price : double
                                     o Lifecycle may be managed
end                                  o Allow use of sliding windows


                                o   “All events are facts, but not all
                                    facts are events.”
Temporal Reasoning


o   Semantics for:
    o time: discrete

    o events: point-in-time and interval

o   Ability to express temporal relationships:
    o Allen’s 13 temporal operators




o   James F. Allen defined the 13 possible temporal relations
    between two events.
o   Eiko Yoneki and Jean Bacon defined a unified semantics
    for event correlation over time and space.
Temporal Relationships


rule “Shipment not picked up in time”
when
  Shipment( $pickupTime : scheduledPickupTime )
  not ShipmentPickup( this before $pickupTime )
then
   // shipment not picked up... action required.
end
Temporal Relationships


rule “Shipment not picked up in time”
when
  Shipment( $pickupTime : scheduledPickupTime )
  not ShipmentPickup( this before $pickupTime )
then
   // shipment not picked up... Action required.
end


                               Temporal
                              Relationship
Allen’s 13 Temporal Operators


                    Point-Point   Point-Interval   Interval-Interval

                A
 A before B     B

                A
 A meets B      B

                A
A overlaps B
                B

                A
A finishes B    B

                A
A includes B    B

                A
 A starts B     B

                A
A coincides B   B
Allen’s 13 Temporal Operators


                      Point-Point   Point-Interval   Interval-Interval

                  A
   A after B      B

                  A
  A metBy B       B

                  A
A overlapedBy B
                  B

                  A
A finishedBy B    B

                  A
  A during B      B

                  A
  A finishes B    B
Streams : Simple Example Scenario
Stream Support (entry-points)


o   A scoping abstraction for stream support
     o Rule compiler gather all entry-point declarations and
       expose them through the session API
     o Engine manages all the scoping and synchronization
       behind the scenes.

rule “Stock Trade Correlation”
rule “Stock Trade Correlation”
when
when
      $c : Customer( type == “VIP” )
      $c : Customer( type == “VIP” )
      BuyOrderEvent( customer == $c, $id : id ) from entry-point “Home Broker Stream”
      BuyOrderEvent( customer == $c, $id : id ) from entry-point “Home Broker Stream”
    BuyAckEvent( sourceEvent == $id ) from entry-point “Stock Trader Stream”
     BuyAckEvent( sourceEvent == $id ) from entry-point “Stock Trader Stream”
then
then
      // take some action
      // take some action
end
end
Cloud Mode, Stream Mode, Session Clock



             CLOUD                             STREAM
•   No notion of “flow of time”:   •   Notion of “flow of time”:
    the engine sees all facts          concept of “now”
    without regard to time         •   Session Clock has an active
•   No attached Session Clock          role synchronizing the
•   No requirements on event           reasoning
    ordering                       •   Event Streams must be
•   No automatic event lifecycle       ordered
    management                     •   Automatic event lifecycle
•   No sliding window support          management
                                   •   Sliding window support
                                   •   Automatic rule delaying on
                                       absence of facts
Reference Clock


o   Reference clock defines the flow of time

o   Named Session Clock
    o is assigned to each session created

o   Synchronizes time sensitive operations
    o duration rules

    o event streams

    o process timers

    o sliding windows
Session Clock


o Uses the strategy pattern and multiple implementations:
   o Real-time operation
   o Tests
   o Simulations
   o etc
Session Clock


o Selecting the session clock:
   o API:

      KnowledgeSessionConfiguration conf = ...
      conf.setOption( ClockTypeOption.get( “realtime” ) );




   o System Property or Configuration File:

      drools.clockType = pseudo
Sliding Window Support


o   Allows reasoning over a moving window of “interest”
     o Time
     o Length

                      Sliding window 1




                           Sliding window 2
Sliding Window Support


o   Allows reasoning over a moving window of “interest”
     o Time
     o Length

                      Sliding window 1




                           Sliding window 2




                         Joined window
Sliding Window Support


o   Allows reasoning over a moving window of “interest”
     o Time
     o Length

rule “Average Order Value over 12 hours”
rule “Average Order Value over 12 hours”
when
when
      $c : Customer()
      $c : Customer()
      $a : Number() from accumulate (
      $a : Number() from accumulate (
                BuyOrder( customer == $c, $p : price )
                BuyOrder( customer == $c, $p : price )
                over window:time( 12h ),
                over window:time( 12h ),
                average( $p ) )
                average( $p ) )
then
then
      // do something
      // do something
end
end
Delaying Rules


o Negative patterns may require rule firings to be delayed.

rule “Order timeout”
rule “Order timeout”
when
when
      $bse : BuyShares ( $id : id )
      $bse : BuyShares ( $id : id )
      not BuySharesAck( id == $id, this after[0s,30s] $bse )
      not BuySharesAck( id == $id, this after[0s,30s] $bse )
then
then
      // Buy order was not acknowledged. Cancel operation
      // Buy order was not acknowledged. Cancel operation
      // by timeout.
      // by timeout.
end
end
Delaying Rules


o Negative patterns may require rule firings to be delayed.

rule “Order timeout”
rule “Order timeout”
when
when
      $bse : BuyShares ( $id : id )
      $bse : BuyShares ( $id : id )
      not BuySharesAck( id == $id, this after[0s,30s] $bse )
      not BuySharesAck( id == $id, this after[0s,30s] $bse )
then
then
      // Buy order was not acknowledged. Cancel operation
      // Buy order was not acknowledged. Cancel operation
      // by timeout.
      // by timeout.
end
end



 Forces the rule to wait for 30 seconds before firing, because the
            acknowledgement may arrive at any time!
Temporal Dimension


o   Requires the support to the temporal dimension
    o A rule/query might match in a given point in time, and not

      match in the subsequent point in time

o   That is the single most difficult requirement to support in a
    way that the engine:
    o stays deterministic

    o stays a high-performance engine

o   Achieved mostly by compile time optimizations that enable:
    o constraint tightening

    o match space narrowing

    o memory management
Temporal Dimension Support


o   CEP scenarios are stateful by nature.
o   Events usually are only interesting during a short period of
    time.
o   Hard for applications to know when events are not
    necessary anymore
     o Temporal constraints and sliding windows describe such
       “window of interest”
Simple Example Rule

rule “Bag was lost”
rule “Bag was lost”
when
when
      $b : BagScannedEvent() from entry-point “check-in”
      $b : BagScannedEvent() from entry-point “check-in”
      not BagScannedEvent( id == $b.id, this after[0s,5m] $b )
      not BagScannedEvent( id == $b.id, this after[0s,5m] $b )
          from entry-point “pre-load”
          from entry-point “pre-load”
then
then
      // Bag was lost, do something
      // Bag was lost, do something
end
end




      Easy to “see” that the only temporal relationship between the
               events defines a 5 minutes interest window.
Abstract Example Rule

rule “Abstract event relationship example”
rule “Abstract event relationship example”
when
when
      $a : A()
      $a : A()
      $b : B( this after[-2, 2] $a )
      $b : B( this after[-2, 2] $a )
      $c : C( this after[-3, 4] $a )
      $c : C( this after[-3, 4] $a )
      $d : D( this after[ 1, 2] $b, this after[2,3] $c)
      $d : D( this after[ 1, 2] $b, this after[2,3] $c)
      not
      not   E( this after[ 1,10] $d )
            E( this after[ 1,10] $d )
then
then
      // Bag was lost, do something
      // Bag was lost, do something
end
end


      How about now? What is the temporal relationship between
                             A and E?
Temporal Dependency Matrix


        [-2,2]          B          [1,2]
                                                         [1,10]
    A                                       D                             E

        [-3,4]          C          [2,3]
                                                         Constraint tightening

           A                B              C             D           E

A          [ 0, 0 ]         [ -2, 2 ]      [ -3, 2 ]     [ -1, 4 ]   [ 0, 14 ]
B          [ -2, 2 ]        [ 0, 0 ]       [ -2, 0 ]     [ 1, 2 ]    [ 2, 12 ]
C          [ -2, 3 ]        [ 0, 2 ]       [ 0, 0 ]      [ 2, 3 ]    [ 3, 13 ]
D          [ -4, 1 ]        [ -2, -1 ]     [ -3, -2 ]    [ 0, 0 ]    [ 1, 10 ]
E          [ -14, 0 ]       [ -12, -2 ]    [ -13, -3 ]   [-10,-1 ]   [ 0, 0 ]
Q&A

o   Drools project site:
     o http://www.drools.org ( http://www.jboss.org/drools/ )

o   Documentation:
     o http://www.jboss.org/drools/documentation.html




                 Edson Tirelli – etirelli@redhat.com
1 of 42

Recommended

Sqoop on Spark for Data Ingestion by
Sqoop on Spark for Data IngestionSqoop on Spark for Data Ingestion
Sqoop on Spark for Data IngestionDataWorks Summit
16.3K views42 slides
Hadoop Strata Talk - Uber, your hadoop has arrived by
Hadoop Strata Talk - Uber, your hadoop has arrived Hadoop Strata Talk - Uber, your hadoop has arrived
Hadoop Strata Talk - Uber, your hadoop has arrived Vinoth Chandar
4.6K views47 slides
Glass fish performance tuning tips from the field by
Glass fish performance tuning tips from the fieldGlass fish performance tuning tips from the field
Glass fish performance tuning tips from the fieldPayara
4.9K views39 slides
user Behavior Analysis with Session Windows and Apache Kafka's Streams API by
user Behavior Analysis with Session Windows and Apache Kafka's Streams APIuser Behavior Analysis with Session Windows and Apache Kafka's Streams API
user Behavior Analysis with Session Windows and Apache Kafka's Streams APIconfluent
4.6K views35 slides
Building better Node.js applications on MariaDB by
Building better Node.js applications on MariaDBBuilding better Node.js applications on MariaDB
Building better Node.js applications on MariaDBMariaDB plc
11.5K views58 slides
Introductory Overview to Managing AWS with Terraform by
Introductory Overview to Managing AWS with TerraformIntroductory Overview to Managing AWS with Terraform
Introductory Overview to Managing AWS with TerraformMichael Heyns
613 views58 slides

More Related Content

What's hot

Kafka monitoring using Prometheus and Grafana by
Kafka monitoring using Prometheus and GrafanaKafka monitoring using Prometheus and Grafana
Kafka monitoring using Prometheus and Grafanawonyong hwang
247 views28 slides
Securing Kafka by
Securing Kafka Securing Kafka
Securing Kafka confluent
14.6K views35 slides
Deploying Flink on Kubernetes - David Anderson by
 Deploying Flink on Kubernetes - David Anderson Deploying Flink on Kubernetes - David Anderson
Deploying Flink on Kubernetes - David AndersonVerverica
2K views48 slides
Managing 2000 Node Cluster with Ambari by
Managing 2000 Node Cluster with AmbariManaging 2000 Node Cluster with Ambari
Managing 2000 Node Cluster with AmbariDataWorks Summit
17.1K views51 slides
BI, Reporting and Analytics on Apache Cassandra by
BI, Reporting and Analytics on Apache CassandraBI, Reporting and Analytics on Apache Cassandra
BI, Reporting and Analytics on Apache CassandraVictor Coustenoble
27K views39 slides
Hive, Presto, and Spark on TPC-DS benchmark by
Hive, Presto, and Spark on TPC-DS benchmarkHive, Presto, and Spark on TPC-DS benchmark
Hive, Presto, and Spark on TPC-DS benchmarkDongwon Kim
9.6K views19 slides

What's hot(20)

Kafka monitoring using Prometheus and Grafana by wonyong hwang
Kafka monitoring using Prometheus and GrafanaKafka monitoring using Prometheus and Grafana
Kafka monitoring using Prometheus and Grafana
wonyong hwang247 views
Securing Kafka by confluent
Securing Kafka Securing Kafka
Securing Kafka
confluent14.6K views
Deploying Flink on Kubernetes - David Anderson by Ververica
 Deploying Flink on Kubernetes - David Anderson Deploying Flink on Kubernetes - David Anderson
Deploying Flink on Kubernetes - David Anderson
Ververica 2K views
Managing 2000 Node Cluster with Ambari by DataWorks Summit
Managing 2000 Node Cluster with AmbariManaging 2000 Node Cluster with Ambari
Managing 2000 Node Cluster with Ambari
DataWorks Summit17.1K views
BI, Reporting and Analytics on Apache Cassandra by Victor Coustenoble
BI, Reporting and Analytics on Apache CassandraBI, Reporting and Analytics on Apache Cassandra
BI, Reporting and Analytics on Apache Cassandra
Victor Coustenoble27K views
Hive, Presto, and Spark on TPC-DS benchmark by Dongwon Kim
Hive, Presto, and Spark on TPC-DS benchmarkHive, Presto, and Spark on TPC-DS benchmark
Hive, Presto, and Spark on TPC-DS benchmark
Dongwon Kim9.6K views
Stream processing using Kafka by Knoldus Inc.
Stream processing using KafkaStream processing using Kafka
Stream processing using Kafka
Knoldus Inc.1.6K views
Wily introscope 7.1 installation guide by Imam Nurhadi
Wily introscope 7.1   installation guideWily introscope 7.1   installation guide
Wily introscope 7.1 installation guide
Imam Nurhadi5.2K views
Reactive Stream Processing with Akka Streams by Konrad Malawski
Reactive Stream Processing with Akka StreamsReactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka Streams
Konrad Malawski14.2K views
Developing Real-Time Data Pipelines with Apache Kafka by Joe Stein
Developing Real-Time Data Pipelines with Apache KafkaDeveloping Real-Time Data Pipelines with Apache Kafka
Developing Real-Time Data Pipelines with Apache Kafka
Joe Stein61.4K views
Impala Architecture presentation by hadooparchbook
Impala Architecture presentationImpala Architecture presentation
Impala Architecture presentation
hadooparchbook10.6K views
Deploying Confluent Platform for Production by confluent
Deploying Confluent Platform for ProductionDeploying Confluent Platform for Production
Deploying Confluent Platform for Production
confluent4.8K views
Where is my bottleneck? Performance troubleshooting in Flink by Flink Forward
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in Flink
Flink Forward533 views
Leveraging Docker for Hadoop build automation and Big Data stack provisioning by DataWorks Summit
Leveraging Docker for Hadoop build automation and Big Data stack provisioningLeveraging Docker for Hadoop build automation and Big Data stack provisioning
Leveraging Docker for Hadoop build automation and Big Data stack provisioning
DataWorks Summit1.4K views
Apache Ambari: Past, Present, Future by Hortonworks
Apache Ambari: Past, Present, FutureApache Ambari: Past, Present, Future
Apache Ambari: Past, Present, Future
Hortonworks3.2K views
Distributed Locking in Kubernetes by Rafał Leszko
Distributed Locking in KubernetesDistributed Locking in Kubernetes
Distributed Locking in Kubernetes
Rafał Leszko2K views
Introduction to Kafka Streams by Guozhang Wang
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
Guozhang Wang29.7K views
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes by DataWorks Summit
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on KubernetesApache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
DataWorks Summit3.3K views

Viewers also liked

Rule Engine Evaluation for Complex Event Processing by
Rule Engine Evaluation for Complex Event ProcessingRule Engine Evaluation for Complex Event Processing
Rule Engine Evaluation for Complex Event ProcessingChandra Divi
5.9K views17 slides
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE by
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTEJBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTEtsurdilovic
14.8K views78 slides
Drools New York City workshop 2011 by
Drools New York City workshop 2011Drools New York City workshop 2011
Drools New York City workshop 2011Geoffrey De Smet
1.7K views111 slides
JUDCon India 2012 Drools Fusion by
JUDCon  India 2012 Drools FusionJUDCon  India 2012 Drools Fusion
JUDCon India 2012 Drools FusionMark Proctor
2.2K views68 slides
Introducing Drools by
Introducing DroolsIntroducing Drools
Introducing DroolsMario Fusco
8.2K views28 slides
Complex Event Processing by
Complex Event ProcessingComplex Event Processing
Complex Event ProcessingMatthew Versaggi
1.4K views13 slides

Viewers also liked(19)

Rule Engine Evaluation for Complex Event Processing by Chandra Divi
Rule Engine Evaluation for Complex Event ProcessingRule Engine Evaluation for Complex Event Processing
Rule Engine Evaluation for Complex Event Processing
Chandra Divi5.9K views
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE by tsurdilovic
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTEJBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE
tsurdilovic14.8K views
Drools New York City workshop 2011 by Geoffrey De Smet
Drools New York City workshop 2011Drools New York City workshop 2011
Drools New York City workshop 2011
Geoffrey De Smet1.7K views
JUDCon India 2012 Drools Fusion by Mark Proctor
JUDCon  India 2012 Drools FusionJUDCon  India 2012 Drools Fusion
JUDCon India 2012 Drools Fusion
Mark Proctor2.2K views
Introducing Drools by Mario Fusco
Introducing DroolsIntroducing Drools
Introducing Drools
Mario Fusco8.2K views
Siddhi: A Second Look at Complex Event Processing Implementations by Srinath Perera
Siddhi: A Second Look at Complex Event Processing ImplementationsSiddhi: A Second Look at Complex Event Processing Implementations
Siddhi: A Second Look at Complex Event Processing Implementations
Srinath Perera17.4K views
Internet of Things and Complex event processing (CEP)/Data fusion by BAINIDA
Internet of Things and Complex event processing (CEP)/Data fusionInternet of Things and Complex event processing (CEP)/Data fusion
Internet of Things and Complex event processing (CEP)/Data fusion
BAINIDA1.5K views
Drools 6.0 (Red Hat Summit) by Mark Proctor
Drools 6.0 (Red Hat Summit)Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)
Mark Proctor37.4K views
Building Real-time CEP Application with Open Source Projects by Ted Won
Building Real-time CEP Application with Open Source Projects Building Real-time CEP Application with Open Source Projects
Building Real-time CEP Application with Open Source Projects
Ted Won4.9K views
Oracle R12.1.3 Costing Overview by Pritesh Mogane
Oracle R12.1.3 Costing OverviewOracle R12.1.3 Costing Overview
Oracle R12.1.3 Costing Overview
Pritesh Mogane26.4K views
Complex Event Processing: What?, Why?, How? by Fabien Coppens
Complex Event Processing: What?, Why?, How?Complex Event Processing: What?, Why?, How?
Complex Event Processing: What?, Why?, How?
Fabien Coppens1.4K views
Applying complex event processing (2010-10-11) by Geoffrey De Smet
Applying complex event processing (2010-10-11)Applying complex event processing (2010-10-11)
Applying complex event processing (2010-10-11)
Geoffrey De Smet1.8K views
Semantic Complex Event Processing at Sem Tech 2010 by Adrian Paschke
Semantic Complex Event Processing at Sem Tech 2010Semantic Complex Event Processing at Sem Tech 2010
Semantic Complex Event Processing at Sem Tech 2010
Adrian Paschke3.9K views
Scalable complex event processing on samza @UBER by Shuyi Chen
Scalable complex event processing on samza @UBERScalable complex event processing on samza @UBER
Scalable complex event processing on samza @UBER
Shuyi Chen4.8K views
Big data streams, Internet of Things, and Complex Event Processing Improve So... by Chris Haddad
Big data streams, Internet of Things, and Complex Event Processing Improve So...Big data streams, Internet of Things, and Complex Event Processing Improve So...
Big data streams, Internet of Things, and Complex Event Processing Improve So...
Chris Haddad5.2K views
Semantic Complex Event Processing by Adrian Paschke
Semantic Complex Event ProcessingSemantic Complex Event Processing
Semantic Complex Event Processing
Adrian Paschke10.5K views

Similar to Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011

st - demystifying complext event processing by
st - demystifying complext event processingst - demystifying complext event processing
st - demystifying complext event processingGeoffrey De Smet
1.2K views17 slides
Aaai 2011 event processing tutorial by
Aaai 2011 event processing tutorialAaai 2011 event processing tutorial
Aaai 2011 event processing tutorialOpher Etzion
2.6K views130 slides
A Model of Events for Integrating Event-based Information in Complex Socio-te... by
A Model of Events for Integrating Event-based Information in Complex Socio-te...A Model of Events for Integrating Event-based Information in Complex Socio-te...
A Model of Events for Integrating Event-based Information in Complex Socio-te...Ansgar Scherp
991 views28 slides
Vldb 2010 event processing tutorial by
Vldb 2010 event processing tutorialVldb 2010 event processing tutorial
Vldb 2010 event processing tutorialOpher Etzion
1.5K views88 slides
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time... by
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...Zhenzhong Xu
218 views70 slides
Osdc Complex Event Processing by
Osdc Complex Event ProcessingOsdc Complex Event Processing
Osdc Complex Event ProcessingMichael Neale
969 views31 slides

Similar to Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011(20)

st - demystifying complext event processing by Geoffrey De Smet
st - demystifying complext event processingst - demystifying complext event processing
st - demystifying complext event processing
Geoffrey De Smet1.2K views
Aaai 2011 event processing tutorial by Opher Etzion
Aaai 2011 event processing tutorialAaai 2011 event processing tutorial
Aaai 2011 event processing tutorial
Opher Etzion2.6K views
A Model of Events for Integrating Event-based Information in Complex Socio-te... by Ansgar Scherp
A Model of Events for Integrating Event-based Information in Complex Socio-te...A Model of Events for Integrating Event-based Information in Complex Socio-te...
A Model of Events for Integrating Event-based Information in Complex Socio-te...
Ansgar Scherp991 views
Vldb 2010 event processing tutorial by Opher Etzion
Vldb 2010 event processing tutorialVldb 2010 event processing tutorial
Vldb 2010 event processing tutorial
Opher Etzion1.5K views
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time... by Zhenzhong Xu
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...
Zhenzhong Xu218 views
Osdc Complex Event Processing by Michael Neale
Osdc Complex Event ProcessingOsdc Complex Event Processing
Osdc Complex Event Processing
Michael Neale969 views
SOA Pattern Event Driven Messaging by WSO2
SOA Pattern Event Driven MessagingSOA Pattern Event Driven Messaging
SOA Pattern Event Driven Messaging
WSO24.1K views
Proposed Event Processing Definitions ,September 20, 2006 by Tim Bass
Proposed Event Processing Definitions,September 20, 2006Proposed Event Processing Definitions,September 20, 2006
Proposed Event Processing Definitions ,September 20, 2006
Tim Bass959 views
FIWARE CEP GE introduction, ICT 2015 by ishkin
FIWARE CEP GE introduction, ICT 2015FIWARE CEP GE introduction, ICT 2015
FIWARE CEP GE introduction, ICT 2015
ishkin438 views
Mythbusters: Event Stream Processing v. Complex Event Processing by Tim Bass
Mythbusters: Event Stream Processing v. Complex Event ProcessingMythbusters: Event Stream Processing v. Complex Event Processing
Mythbusters: Event Stream Processing v. Complex Event Processing
Tim Bass8.6K views
Events, Streams, Devops and Speed - The Next Generation of Application Archit... by confluent
Events, Streams, Devops and Speed - The Next Generation of Application Archit...Events, Streams, Devops and Speed - The Next Generation of Application Archit...
Events, Streams, Devops and Speed - The Next Generation of Application Archit...
confluent230 views
Complex Event Processing by John Plummer
Complex Event ProcessingComplex Event Processing
Complex Event Processing
John Plummer4K views
GOTO LONDON 2016: Concursus Event sourcing Evolved (Updated) by OpenCredo
GOTO LONDON 2016: Concursus Event sourcing Evolved (Updated)GOTO LONDON 2016: Concursus Event sourcing Evolved (Updated)
GOTO LONDON 2016: Concursus Event sourcing Evolved (Updated)
OpenCredo478 views
Open Source Event Processing for Sensor Fusion Applications by guestc4ce526
Open Source Event Processing for Sensor Fusion ApplicationsOpen Source Event Processing for Sensor Fusion Applications
Open Source Event Processing for Sensor Fusion Applications
guestc4ce5263.7K views
Need for Async: Hot pursuit for scalable applications by Konrad Malawski
Need for Async: Hot pursuit for scalable applicationsNeed for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applications
Konrad Malawski6.2K views
WSO2 Product Release Webinar - WSO2 Complex Event Processor by WSO2
WSO2 Product Release Webinar - WSO2 Complex Event ProcessorWSO2 Product Release Webinar - WSO2 Complex Event Processor
WSO2 Product Release Webinar - WSO2 Complex Event Processor
WSO21.5K views

More from Geoffrey De Smet

Drools planner - 2012-10-23 IntelliFest 2012 by
Drools planner - 2012-10-23 IntelliFest 2012Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012Geoffrey De Smet
1.4K views83 slides
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference by
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev ConferenceWhat is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev ConferenceGeoffrey De Smet
2.6K views87 slides
2012 02-04 fosdem 2012 - drools planner by
2012 02-04 fosdem 2012 - drools planner2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools plannerGeoffrey De Smet
1.5K views99 slides
JUDCon London 2011 - Bin packing with drools planner by example by
JUDCon London 2011 - Bin packing with drools planner by exampleJUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by exampleGeoffrey De Smet
2.8K views93 slides
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planning by
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planningDrools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planningGeoffrey De Smet
3.1K views53 slides
JBoss World 2011 - Drools by
JBoss World 2011 - DroolsJBoss World 2011 - Drools
JBoss World 2011 - DroolsGeoffrey De Smet
1.7K views89 slides

More from Geoffrey De Smet(20)

Drools planner - 2012-10-23 IntelliFest 2012 by Geoffrey De Smet
Drools planner - 2012-10-23 IntelliFest 2012Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Geoffrey De Smet1.4K views
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference by Geoffrey De Smet
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev ConferenceWhat is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
Geoffrey De Smet2.6K views
2012 02-04 fosdem 2012 - drools planner by Geoffrey De Smet
2012 02-04 fosdem 2012 - drools planner2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools planner
Geoffrey De Smet1.5K views
JUDCon London 2011 - Bin packing with drools planner by example by Geoffrey De Smet
JUDCon London 2011 - Bin packing with drools planner by exampleJUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by example
Geoffrey De Smet2.8K views
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planning by Geoffrey De Smet
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planningDrools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
Geoffrey De Smet3.1K views
2011-03-29 London - Decision tables in depth (Michael Anstis) by Geoffrey De Smet
2011-03-29 London - Decision tables in depth (Michael Anstis)2011-03-29 London - Decision tables in depth (Michael Anstis)
2011-03-29 London - Decision tables in depth (Michael Anstis)
Geoffrey De Smet4K views
2011-03-29 London - Why do I need the guvnor BRMS? by Geoffrey De Smet
2011-03-29 London - Why do I need the guvnor BRMS?2011-03-29 London - Why do I need the guvnor BRMS?
2011-03-29 London - Why do I need the guvnor BRMS?
Geoffrey De Smet5.4K views
2011-03-09 London - Drools Planner in a nutshell by Geoffrey De Smet
2011-03-09 London - Drools Planner in a nutshell2011-03-09 London - Drools Planner in a nutshell
2011-03-09 London - Drools Planner in a nutshell
Geoffrey De Smet1.3K views
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor) by Geoffrey De Smet
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)
Geoffrey De Smet1.1K views
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09) by Geoffrey De Smet
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)
Geoffrey De Smet6.1K views
Drooling for drools (JBoss webex) by Geoffrey De Smet
Drooling for drools (JBoss webex)Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)
Geoffrey De Smet1.8K views
Developing applications with rules, workflow and event processing (it@cork 2010) by Geoffrey De Smet
Developing applications with rules, workflow and event processing (it@cork 2010)Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)
Geoffrey De Smet2.5K views
Hybrid rule engines (rulesfest 2010) by Geoffrey De Smet
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)
Geoffrey De Smet1.2K views
Towards unified knowledge management platform (rulefest 2010) by Geoffrey De Smet
Towards unified knowledge management platform (rulefest 2010)Towards unified knowledge management platform (rulefest 2010)
Towards unified knowledge management platform (rulefest 2010)
Geoffrey De Smet1K views
2010 04-20 san diego bootcamp - drools planner - use cases by Geoffrey De Smet
2010 04-20 san diego bootcamp - drools planner - use cases2010 04-20 san diego bootcamp - drools planner - use cases
2010 04-20 san diego bootcamp - drools planner - use cases
Geoffrey De Smet1K views

Recently uploaded

virtual reality.pptx by
virtual reality.pptxvirtual reality.pptx
virtual reality.pptxG036GaikwadSnehal
14 views15 slides
Case Study Copenhagen Energy and Business Central.pdf by
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdfAitana
16 views3 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
40 views69 slides
20231123_Camunda Meetup Vienna.pdf by
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
41 views73 slides
"Surviving highload with Node.js", Andrii Shumada by
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada Fwdays
22 views29 slides
Melek BEN MAHMOUD.pdf by
Melek BEN MAHMOUD.pdfMelek BEN MAHMOUD.pdf
Melek BEN MAHMOUD.pdfMelekBenMahmoud
14 views1 slide

Recently uploaded(20)

Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker40 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays22 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson92 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely25 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software280 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman36 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2218 views
Future of AR - Facebook Presentation by ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56115 views

Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011

  • 1. Applying Complex Event Processing with Drools Fusion Edson Tirelli etirelli@redhat.com Lead CEP Engineer JBoss, a Division of Red Hat
  • 2. Agenda o Brief introduction on CEP and Terminology o Drools Vision o Drools Fusion: Complex Event Processing extensions o Event Declaration and Semantics o Event Cloud, Streams and the Session Clock o Temporal Reasoning o Sliding Window Support o Streams Support o Memory Management o Questions & Answers
  • 3. Terminology: Event “An event is an observable occurrence.” “An event in the Unified Modeling Language is a notable occurrence at a particular point in time.” http://www.wikipedia.org “Anything that happens, or is contemplated as happening.” “An object that represents, encodes or records an event, generally for the purpose of computer processing” http://complexevents.com
  • 4. Terminology: Event For the scope of this presentation: “An event is a significant change of state at a particular point in time”
  • 5. Terminology: Complex Event “Complex Event, is an abstraction of other events called its members.” o Examples: o The 1929 stock market crash – an abstraction denoting many thousands of member events, including individual stock trades) o The 2004 Indonesian Tsunami – an abstraction of many natural events o A completed stock purchase -an abstraction of the events in a transaction to purchase the stock o A successful on-line shopping cart checkout – an abstraction of shopping cart events on an on-line website  Source: http://complexevents.com
  • 6. Terminology: CEP “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. 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.” -- wikipedia
  • 7. Terminology: CEP o Examples: o Emergency Response Systems o Credit Card Fraud Detection o Logistics Real-Time Awareness solution o Neonatal ICU: infant vital signs monitoring
  • 8. Terminology: CEP vs ESP Complex Event Processing, or CEP, and Event Stream Processing, or ESP, are two technologies that were born separate, but converged. ● An oversimplification: In their origins...  Event Stream Processing focused on the ability to process high volume streams of events.  Complex Event Processing focused on defining, detecting and processing the relationships among events.
  • 9. Terminology: CEP and ESP For the scope of this presentation: “CEP is used as a common term meaning both CEP and ESP.”
  • 10. Terminology: EDA “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 "a significant change in state"[1]. For example, when a consumer purchases a car, the car's state changes from "for sale" to "sold". 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
  • 11. EDA vs CEP CEP is a component of the EDA Source: http://elementallinks.typepad.com/.shared/image.html?/photos/uncategorized/simple_event_flow.gif
  • 12. EDA vs SOA o EDA is **not** SOA 2.0 o Complementary architectures o Metaphor o In our body: o SOA is used to build our muscles and organs o EDA is used to build our sensory system
  • 13. EDA vs SOA Source: http://soa-eda.blogspot.com/2006/11/how-eda-extends-soa-and-why-it-is.html
  • 14. Complex Event Processing o A few characteristics of common CEP scenarios: o Huge volume of events, but only a few of real interest o Usually events are immutable o Usually queries/rules have to run in reactive mode o Strong temporal relationships between events o Individual events are usually not important o The composition and aggregation of events is important
  • 15. Drools Vision “A common platform to model and govern the business logic of the enterprise.”
  • 17. Drools Fusion: Enables… • Event Detection: • From an event cloud or set of streams, select all the meaningful events, and only them. • [Temporal] Event Correlation: • Ability to correlate events and facts declaring both temporal and non-temporal constraints between them. • Ability to reason over event aggregation • Event Abstraction: • Ability to compose complex events from atomic events AND reason over them
  • 18. Drools Fusion o Features: o Event Semantics as First Class Citizens o Allow Detection, Correlation and Composition o Temporal Constraints o Session Clock o Stream Processing o Sliding Windows o CEP volumes (scalability) o (Re)Active Rules o Data Loaders for Input
  • 19. Demo o Twitter Stream CEP Demo: o Listen to the Twitter Stream API  Twitter4J API  Listens to a random sample of tweets o Detects patterns and reacts  Drools Fusion o Simple one process (multi-thread) demo  Focus on specific features
  • 20. Event Declaration and Semantics // declaring existing class import some.package.VoiceCall o Event semantics: declare VoiceCall o Point-in-time and Interval @role( event ) @timestamp( calltime ) @duration( duration ) end o An event is a fact with a few special characteristics: // generating an event class o Usually immutable, but not declare StockTick @role( event ) enforced o Strong temporal relationships symbol : String price : double o Lifecycle may be managed end o Allow use of sliding windows o “All events are facts, but not all facts are events.”
  • 21. Temporal Reasoning o Semantics for: o time: discrete o events: point-in-time and interval o Ability to express temporal relationships: o Allen’s 13 temporal operators o James F. Allen defined the 13 possible temporal relations between two events. o Eiko Yoneki and Jean Bacon defined a unified semantics for event correlation over time and space.
  • 22. Temporal Relationships rule “Shipment not picked up in time” when Shipment( $pickupTime : scheduledPickupTime ) not ShipmentPickup( this before $pickupTime ) then // shipment not picked up... action required. end
  • 23. Temporal Relationships rule “Shipment not picked up in time” when Shipment( $pickupTime : scheduledPickupTime ) not ShipmentPickup( this before $pickupTime ) then // shipment not picked up... Action required. end Temporal Relationship
  • 24. Allen’s 13 Temporal Operators Point-Point Point-Interval Interval-Interval A A before B B A A meets B B A A overlaps B B A A finishes B B A A includes B B A A starts B B A A coincides B B
  • 25. Allen’s 13 Temporal Operators Point-Point Point-Interval Interval-Interval A A after B B A A metBy B B A A overlapedBy B B A A finishedBy B B A A during B B A A finishes B B
  • 26. Streams : Simple Example Scenario
  • 27. Stream Support (entry-points) o A scoping abstraction for stream support o Rule compiler gather all entry-point declarations and expose them through the session API o Engine manages all the scoping and synchronization behind the scenes. rule “Stock Trade Correlation” rule “Stock Trade Correlation” when when $c : Customer( type == “VIP” ) $c : Customer( type == “VIP” ) BuyOrderEvent( customer == $c, $id : id ) from entry-point “Home Broker Stream” BuyOrderEvent( customer == $c, $id : id ) from entry-point “Home Broker Stream” BuyAckEvent( sourceEvent == $id ) from entry-point “Stock Trader Stream” BuyAckEvent( sourceEvent == $id ) from entry-point “Stock Trader Stream” then then // take some action // take some action end end
  • 28. Cloud Mode, Stream Mode, Session Clock CLOUD STREAM • No notion of “flow of time”: • Notion of “flow of time”: the engine sees all facts concept of “now” without regard to time • Session Clock has an active • No attached Session Clock role synchronizing the • No requirements on event reasoning ordering • Event Streams must be • No automatic event lifecycle ordered management • Automatic event lifecycle • No sliding window support management • Sliding window support • Automatic rule delaying on absence of facts
  • 29. Reference Clock o Reference clock defines the flow of time o Named Session Clock o is assigned to each session created o Synchronizes time sensitive operations o duration rules o event streams o process timers o sliding windows
  • 30. Session Clock o Uses the strategy pattern and multiple implementations: o Real-time operation o Tests o Simulations o etc
  • 31. Session Clock o Selecting the session clock: o API: KnowledgeSessionConfiguration conf = ... conf.setOption( ClockTypeOption.get( “realtime” ) ); o System Property or Configuration File: drools.clockType = pseudo
  • 32. Sliding Window Support o Allows reasoning over a moving window of “interest” o Time o Length Sliding window 1 Sliding window 2
  • 33. Sliding Window Support o Allows reasoning over a moving window of “interest” o Time o Length Sliding window 1 Sliding window 2 Joined window
  • 34. Sliding Window Support o Allows reasoning over a moving window of “interest” o Time o Length rule “Average Order Value over 12 hours” rule “Average Order Value over 12 hours” when when $c : Customer() $c : Customer() $a : Number() from accumulate ( $a : Number() from accumulate ( BuyOrder( customer == $c, $p : price ) BuyOrder( customer == $c, $p : price ) over window:time( 12h ), over window:time( 12h ), average( $p ) ) average( $p ) ) then then // do something // do something end end
  • 35. Delaying Rules o Negative patterns may require rule firings to be delayed. rule “Order timeout” rule “Order timeout” when when $bse : BuyShares ( $id : id ) $bse : BuyShares ( $id : id ) not BuySharesAck( id == $id, this after[0s,30s] $bse ) not BuySharesAck( id == $id, this after[0s,30s] $bse ) then then // Buy order was not acknowledged. Cancel operation // Buy order was not acknowledged. Cancel operation // by timeout. // by timeout. end end
  • 36. Delaying Rules o Negative patterns may require rule firings to be delayed. rule “Order timeout” rule “Order timeout” when when $bse : BuyShares ( $id : id ) $bse : BuyShares ( $id : id ) not BuySharesAck( id == $id, this after[0s,30s] $bse ) not BuySharesAck( id == $id, this after[0s,30s] $bse ) then then // Buy order was not acknowledged. Cancel operation // Buy order was not acknowledged. Cancel operation // by timeout. // by timeout. end end Forces the rule to wait for 30 seconds before firing, because the acknowledgement may arrive at any time!
  • 37. Temporal Dimension o Requires the support to the temporal dimension o A rule/query might match in a given point in time, and not match in the subsequent point in time o That is the single most difficult requirement to support in a way that the engine: o stays deterministic o stays a high-performance engine o Achieved mostly by compile time optimizations that enable: o constraint tightening o match space narrowing o memory management
  • 38. Temporal Dimension Support o CEP scenarios are stateful by nature. o Events usually are only interesting during a short period of time. o Hard for applications to know when events are not necessary anymore o Temporal constraints and sliding windows describe such “window of interest”
  • 39. Simple Example Rule rule “Bag was lost” rule “Bag was lost” when when $b : BagScannedEvent() from entry-point “check-in” $b : BagScannedEvent() from entry-point “check-in” not BagScannedEvent( id == $b.id, this after[0s,5m] $b ) not BagScannedEvent( id == $b.id, this after[0s,5m] $b ) from entry-point “pre-load” from entry-point “pre-load” then then // Bag was lost, do something // Bag was lost, do something end end Easy to “see” that the only temporal relationship between the events defines a 5 minutes interest window.
  • 40. Abstract Example Rule rule “Abstract event relationship example” rule “Abstract event relationship example” when when $a : A() $a : A() $b : B( this after[-2, 2] $a ) $b : B( this after[-2, 2] $a ) $c : C( this after[-3, 4] $a ) $c : C( this after[-3, 4] $a ) $d : D( this after[ 1, 2] $b, this after[2,3] $c) $d : D( this after[ 1, 2] $b, this after[2,3] $c) not not E( this after[ 1,10] $d ) E( this after[ 1,10] $d ) then then // Bag was lost, do something // Bag was lost, do something end end How about now? What is the temporal relationship between A and E?
  • 41. Temporal Dependency Matrix [-2,2] B [1,2] [1,10] A D E [-3,4] C [2,3] Constraint tightening A B C D E A [ 0, 0 ] [ -2, 2 ] [ -3, 2 ] [ -1, 4 ] [ 0, 14 ] B [ -2, 2 ] [ 0, 0 ] [ -2, 0 ] [ 1, 2 ] [ 2, 12 ] C [ -2, 3 ] [ 0, 2 ] [ 0, 0 ] [ 2, 3 ] [ 3, 13 ] D [ -4, 1 ] [ -2, -1 ] [ -3, -2 ] [ 0, 0 ] [ 1, 10 ] E [ -14, 0 ] [ -12, -2 ] [ -13, -3 ] [-10,-1 ] [ 0, 0 ]
  • 42. Q&A o Drools project site: o http://www.drools.org ( http://www.jboss.org/drools/ ) o Documentation: o http://www.jboss.org/drools/documentation.html Edson Tirelli – etirelli@redhat.com