SlideShare a Scribd company logo
1 of 17
Download to read offline
Simple Drools Examples
A couple of simple examples for the JUG Milano meeting.
Matteo Mortari
http://linkedin.com/in/matteomortari
http://github.com/tarilabs
@tari_manga
Drools: effective use-cases
● Business logic changes often
● Rule definition as common language between
Developers, Analysts and Stakeholders
● Framework to support Data Analysis
● Data “cleaning”: filtering, augmentation, ...
● Inference: assert new data, FSM, …
● Time series: Complex Event Processing (CEP)
… and many others!
( Two simple examples )
cit. YouTube: Maccio Capatonda “Burle”
Example #1
Monitor commuting route
● Strike
● Traffic delays
● Multiple notifications
...
Live: http://reex2014-tarilabs.rhcloud.com/
Source: https://github.com/tarilabs/reex2014-rules
Strike announcements
Metro delays
Final result
(demo)
(demo)
(demo)
(demo)
Example #2
Filtering, Inference, CEP, ...
https://github.com/tarilabs/mpes-demo2015/blob/master/src/main/resources/rules.drl
Filtering rules
rule "Filter01"
no-loop
salience 1000
when
$e : ZnetRxIoSampleResponse(
addressAsMacFormat(remoteAddress64) != "00:13:A2:00:40:68:E0:95"
)
then
retract($e);
end
rule "Filter02"
no-loop
salience 1000
when
$e : ZNetRxIoSampleResponse(
addressAsMacFormat(remoteAddress64) == "00:13:A2:00:40:68:E0:95" ,
containsAnalog == false
)
then
retract($e);
end
Inference rules
rule "Detect Docked"
no-loop
when
accumulate ( ZNetRxIoSampleResponse(
containsAnalog == true, $analog1 : analog1
) over window:length( 3 );
$avg : average( $analog1 ),
$count : count( $analog1 );
$avg > 950 , $count == 3
)
not ( DockedEvt() )
then
DockedEvt de = new DockedEvt();
de.setTs(drools.getWorkingMemory().getSessionClock().getCurrentTime());
insert(de);
end
CEP rules
rule "Toothbrush Session"
no-loop
when
$ude : UnDockedEvt()
$de : DockedEvt( this after $ude )
then
long millis = $de.getTs() - $ude.getTs() - 1000;
long mins = millis/1000/60;
long secs = (millis/1000) % 60;
long oscillations = (long) ( (7600.0/60/1000) * millis );
String sentence = "I just used my toothbrush! Total time: "
+( (mins>0)?mins+"m":"" )
+secs+"s "
+"Oscillations: "+oscillations;
LOG.debug("{}", sentence);
onCamel("direct:sentence", sentence);
retract($de);
retract($ude);
end
(live coding & demo)
Thank you!
Thanks JUG Milano
Matteo Mortari
http://linkedin.com/in/matteomortari
http://github.com/tarilabs
@tari_manga

More Related Content

Viewers also liked

syntegra-brochure-11_14b_2014_v3
syntegra-brochure-11_14b_2014_v3syntegra-brochure-11_14b_2014_v3
syntegra-brochure-11_14b_2014_v3Alan Wing-King
 
Magazine
MagazineMagazine
MagazineAHJoshy
 
поступление подушек и одеял
поступление подушек и одеялпоступление подушек и одеял
поступление подушек и одеял84959847778
 
Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...
Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...
Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...Ramesh Dhungel
 
Top Ideas for Wash Sanitation and Hygiene
Top Ideas for Wash Sanitation and HygieneTop Ideas for Wash Sanitation and Hygiene
Top Ideas for Wash Sanitation and HygieneCopenhagen_Consensus
 

Viewers also liked (8)

syntegra-brochure-11_14b_2014_v3
syntegra-brochure-11_14b_2014_v3syntegra-brochure-11_14b_2014_v3
syntegra-brochure-11_14b_2014_v3
 
Itogi 2014.compressed
Itogi 2014.compressedItogi 2014.compressed
Itogi 2014.compressed
 
Magazine
MagazineMagazine
Magazine
 
Editing
EditingEditing
Editing
 
поступление подушек и одеял
поступление подушек и одеялпоступление подушек и одеял
поступление подушек и одеял
 
1 adetuyi oluwafijimi yomi bch084406
1 adetuyi oluwafijimi yomi bch0844061 adetuyi oluwafijimi yomi bch084406
1 adetuyi oluwafijimi yomi bch084406
 
Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...
Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...
Comparison of Latent Heat Flux Using Aerodynamic Methods and Using the Penman...
 
Top Ideas for Wash Sanitation and Hygiene
Top Ideas for Wash Sanitation and HygieneTop Ideas for Wash Sanitation and Hygiene
Top Ideas for Wash Sanitation and Hygiene
 

Similar to Simple Drools Examples

IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015哲也 廣田
 
MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle Databricks
 
Model Drift Monitoring using Tensorflow Model Analysis
Model Drift Monitoring using Tensorflow Model AnalysisModel Drift Monitoring using Tensorflow Model Analysis
Model Drift Monitoring using Tensorflow Model AnalysisVivek Raja P S
 
Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)Brian Brazil
 
Streaming analytics state of the art
Streaming analytics state of the artStreaming analytics state of the art
Streaming analytics state of the artStavros Kontopoulos
 
Kusto (Azure Data Explorer) Training for R&D - January 2019
Kusto (Azure Data Explorer) Training for R&D - January 2019 Kusto (Azure Data Explorer) Training for R&D - January 2019
Kusto (Azure Data Explorer) Training for R&D - January 2019 Tal Bar-Zvi
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysislienhard
 
DotDotPwn v3.0 [GuadalajaraCON 2012]
DotDotPwn v3.0 [GuadalajaraCON 2012]DotDotPwn v3.0 [GuadalajaraCON 2012]
DotDotPwn v3.0 [GuadalajaraCON 2012]Websec México, S.C.
 
ACM DEBS 2015: Realtime Streaming Analytics Patterns
ACM DEBS 2015: Realtime Streaming Analytics PatternsACM DEBS 2015: Realtime Streaming Analytics Patterns
ACM DEBS 2015: Realtime Streaming Analytics PatternsSrinath Perera
 
DEBS 2015 Tutorial : Patterns for Realtime Streaming Analytics
DEBS 2015 Tutorial : Patterns for Realtime Streaming AnalyticsDEBS 2015 Tutorial : Patterns for Realtime Streaming Analytics
DEBS 2015 Tutorial : Patterns for Realtime Streaming AnalyticsSriskandarajah Suhothayan
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-oplbergmans
 
Prometheus: From technical metrics to business observability
Prometheus: From technical metrics to business observabilityPrometheus: From technical metrics to business observability
Prometheus: From technical metrics to business observabilityJulien Pivotto
 
Fast Person Re-Identification for Intelligent Video Surveillance Systems
Fast Person Re-Identification for Intelligent Video Surveillance SystemsFast Person Re-Identification for Intelligent Video Surveillance Systems
Fast Person Re-Identification for Intelligent Video Surveillance SystemsBahram Lavi
 
Data Science for Internet of Things with Ajit Jaokar
Data Science for Internet of Things with Ajit JaokarData Science for Internet of Things with Ajit Jaokar
Data Science for Internet of Things with Ajit JaokarJessica Willis
 
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...ITCamp
 
Performance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsPerformance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsMartin Gutenbrunner
 
Go Observability (in practice)
Go Observability (in practice)Go Observability (in practice)
Go Observability (in practice)Eran Levy
 

Similar to Simple Drools Examples (20)

IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015
 
MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle
 
Model Drift Monitoring using Tensorflow Model Analysis
Model Drift Monitoring using Tensorflow Model AnalysisModel Drift Monitoring using Tensorflow Model Analysis
Model Drift Monitoring using Tensorflow Model Analysis
 
Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)
 
Streaming analytics state of the art
Streaming analytics state of the artStreaming analytics state of the art
Streaming analytics state of the art
 
Kusto (Azure Data Explorer) Training for R&D - January 2019
Kusto (Azure Data Explorer) Training for R&D - January 2019 Kusto (Azure Data Explorer) Training for R&D - January 2019
Kusto (Azure Data Explorer) Training for R&D - January 2019
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysis
 
Guadalajara con 2012
Guadalajara con 2012Guadalajara con 2012
Guadalajara con 2012
 
DotDotPwn v3.0 [GuadalajaraCON 2012]
DotDotPwn v3.0 [GuadalajaraCON 2012]DotDotPwn v3.0 [GuadalajaraCON 2012]
DotDotPwn v3.0 [GuadalajaraCON 2012]
 
ACM DEBS 2015: Realtime Streaming Analytics Patterns
ACM DEBS 2015: Realtime Streaming Analytics PatternsACM DEBS 2015: Realtime Streaming Analytics Patterns
ACM DEBS 2015: Realtime Streaming Analytics Patterns
 
DEBS 2015 Tutorial : Patterns for Realtime Streaming Analytics
DEBS 2015 Tutorial : Patterns for Realtime Streaming AnalyticsDEBS 2015 Tutorial : Patterns for Realtime Streaming Analytics
DEBS 2015 Tutorial : Patterns for Realtime Streaming Analytics
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-op
 
Prometheus: From technical metrics to business observability
Prometheus: From technical metrics to business observabilityPrometheus: From technical metrics to business observability
Prometheus: From technical metrics to business observability
 
Fast Person Re-Identification for Intelligent Video Surveillance Systems
Fast Person Re-Identification for Intelligent Video Surveillance SystemsFast Person Re-Identification for Intelligent Video Surveillance Systems
Fast Person Re-Identification for Intelligent Video Surveillance Systems
 
Msr2021 tutorial-di penta
Msr2021 tutorial-di pentaMsr2021 tutorial-di penta
Msr2021 tutorial-di penta
 
Data Science for Internet of Things with Ajit Jaokar
Data Science for Internet of Things with Ajit JaokarData Science for Internet of Things with Ajit Jaokar
Data Science for Internet of Things with Ajit Jaokar
 
Ajit jaokar slides
Ajit jaokar slidesAjit jaokar slides
Ajit jaokar slides
 
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
 
Performance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsPerformance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environments
 
Go Observability (in practice)
Go Observability (in practice)Go Observability (in practice)
Go Observability (in practice)
 

Recently uploaded

Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...OnePlan Solutions
 
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...CloudMetic
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationElement34
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Henry Schreiner
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Andrea Goulet
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Soroosh Khodami
 
Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMok TH
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfsteffenkarlsson2
 
Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024Chirag Panchal
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionWave PLM
 
architecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfarchitecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfWSO2
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMarkus Moeller
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...naitiksharma1124
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationHelp Desk Migration
 

Recently uploaded (20)

Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptx
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
AI Hackathon.pptx
AI                        Hackathon.pptxAI                        Hackathon.pptx
AI Hackathon.pptx
 
Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
architecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfarchitecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdf
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 

Simple Drools Examples

  • 1. Simple Drools Examples A couple of simple examples for the JUG Milano meeting. Matteo Mortari http://linkedin.com/in/matteomortari http://github.com/tarilabs @tari_manga
  • 2. Drools: effective use-cases ● Business logic changes often ● Rule definition as common language between Developers, Analysts and Stakeholders ● Framework to support Data Analysis ● Data “cleaning”: filtering, augmentation, ... ● Inference: assert new data, FSM, … ● Time series: Complex Event Processing (CEP) … and many others!
  • 3. ( Two simple examples ) cit. YouTube: Maccio Capatonda “Burle”
  • 4. Example #1 Monitor commuting route ● Strike ● Traffic delays ● Multiple notifications ... Live: http://reex2014-tarilabs.rhcloud.com/ Source: https://github.com/tarilabs/reex2014-rules
  • 12. Example #2 Filtering, Inference, CEP, ... https://github.com/tarilabs/mpes-demo2015/blob/master/src/main/resources/rules.drl
  • 13. Filtering rules rule "Filter01" no-loop salience 1000 when $e : ZnetRxIoSampleResponse( addressAsMacFormat(remoteAddress64) != "00:13:A2:00:40:68:E0:95" ) then retract($e); end rule "Filter02" no-loop salience 1000 when $e : ZNetRxIoSampleResponse( addressAsMacFormat(remoteAddress64) == "00:13:A2:00:40:68:E0:95" , containsAnalog == false ) then retract($e); end
  • 14. Inference rules rule "Detect Docked" no-loop when accumulate ( ZNetRxIoSampleResponse( containsAnalog == true, $analog1 : analog1 ) over window:length( 3 ); $avg : average( $analog1 ), $count : count( $analog1 ); $avg > 950 , $count == 3 ) not ( DockedEvt() ) then DockedEvt de = new DockedEvt(); de.setTs(drools.getWorkingMemory().getSessionClock().getCurrentTime()); insert(de); end
  • 15. CEP rules rule "Toothbrush Session" no-loop when $ude : UnDockedEvt() $de : DockedEvt( this after $ude ) then long millis = $de.getTs() - $ude.getTs() - 1000; long mins = millis/1000/60; long secs = (millis/1000) % 60; long oscillations = (long) ( (7600.0/60/1000) * millis ); String sentence = "I just used my toothbrush! Total time: " +( (mins>0)?mins+"m":"" ) +secs+"s " +"Oscillations: "+oscillations; LOG.debug("{}", sentence); onCamel("direct:sentence", sentence); retract($de); retract($ude); end
  • 16. (live coding & demo)
  • 17. Thank you! Thanks JUG Milano Matteo Mortari http://linkedin.com/in/matteomortari http://github.com/tarilabs @tari_manga