8/2/2019 Drools Gateway Jug
1/107
The Business Logic Integration Platform
Drools and
the BRMS
Ray PloskiDirector - Developer Experience
8/2/2019 Drools Gateway Jug
2/107
Agenda
The Concepts
A Simple Example and Demo
Projects OverviewBest practices integrating Drools into
your development process
Learning more, getting involved andgetting support
8/2/2019 Drools Gateway Jug
3/107
What is Drools?
Planner
8/2/2019 Drools Gateway Jug
4/107
8/2/2019 Drools Gateway Jug
5/107
What is JBoss BRMS?
A common and complete platform to model and govern the business logic of the
enterprise
JBoss Enterprise BRMS
Single, integrated, certified
distributions Extensive Q/A Process Industry-leading Support Documentation Secure, Production-level
Configurations Multi-year Errata Policy
BRMS
8/2/2019 Drools Gateway Jug
6/107
6
JBoss Enterprise BRMS
n Each JBoss Enterprise Middleware platform goes through a 5 phase delivery methodology that
involves many traditional elements of the software development lifecyle:
PlatformCandidateRelease(s)
QualityAssurance
Drools Projects
JBoss.orgEngineers
1
ProductRequirements
Definition
Product
Management
2Platform Testing,
Certification &Documentation
JBoss QA, DocumentationTeam, Certified Partners
4
JBossEnterprise
BRMS
Platform ComponentEngineering & Integration
JBossProductization
Engineers
3 5Platform Release
(General Availability)
JBoss ReleaseEngineering
DeliveryPhase
Produ
ctizationTeam
8/2/2019 Drools Gateway Jug
7/107
The
Concepts
8/2/2019 Drools Gateway Jug
8/107
The Typical SDLC
8/2/2019 Drools Gateway Jug
9/107
The Typical SDLC
8/2/2019 Drools Gateway Jug
10/107
The Typical SDLC
8/2/2019 Drools Gateway Jug
11/107
The Typical SDLC
8/2/2019 Drools Gateway Jug
12/107
The Typical SDLC
8/2/2019 Drools Gateway Jug
13/107
The Typical SDLC
8/2/2019 Drools Gateway Jug
14/107
The Typical SDLC
8/2/2019 Drools Gateway Jug
15/107
Extract the Logic
8/2/2019 Drools Gateway Jug
16/107
Extract the Logic
Separate integration codebasefrom business logic and into a
rules engine
8/2/2019 Drools Gateway Jug
17/107
Extract the Logic
Separate integration codebasefrom business logic and into a
rules engine Goal: Remove the requirements
churn and complexity
8/2/2019 Drools Gateway Jug
18/107
Extract the Logic
Separate integration codebasefrom business logic and into a
rules engine Goal: Remove the requirements
churn and complexity
Goal: Empower your DomainExperts to directly author rules
8/2/2019 Drools Gateway Jug
19/107
8/2/2019 Drools Gateway Jug
20/107
Business Logic
Rules
8/2/2019 Drools Gateway Jug
21/107
Business Logic
Rules
Process
8/2/2019 Drools Gateway Jug
22/107
Business Logic
Rules
Process
Response to Events
8/2/2019 Drools Gateway Jug
23/107
Business Logic
Rules
Process
Response to Events
Planning Problems
8/2/2019 Drools Gateway Jug
24/107
Why a Unified Approach?
Extend Rules Engine to handle process State
Extend the Engine to handle Events
Integration provides
Simplicity Performance
Manageability
Integration of Features
8/2/2019 Drools Gateway Jug
25/107
What is a Rules Engine?
8/2/2019 Drools Gateway Jug
26/107
What is a Rules Engine?
Ambiguous Term
8/2/2019 Drools Gateway Jug
27/107
What is a Rules Engine?
Ambiguous TermInference Engine Concepts Clarify
Scales to a large number of rules and
facts
Matches facts against rules to inferconclusions
Conclusions result in actions
Simple two-part structure:
rule XYZ
when
then
8/2/2019 Drools Gateway Jug
28/107
Facts POJOs (Plain Old Java Objects)
Rules engine uses to evaluate conditions
Rules engine can execute POJO methods
Can be loaded from a database viaHibernate, JPA, etc...
Rules engine can modify a facts state
Dynamic Facts
Can be modeled in the Web UI
8/2/2019 Drools Gateway Jug
29/107
Facts POJOs (Plain Old Java Objects)
Rules engine uses to evaluate conditions
Rules engine can execute POJO methods
Can be loaded from a database viaHibernate, JPA, etc...
Rules engine can modify a facts state
Dynamic Facts
Can be modeled in the Web UI
8/2/2019 Drools Gateway Jug
30/107
Fact Model Example
publicclass Room { private String name // getter and setter methods here}publicclass Sprinkler {
private Room room; privatebooleanon; // getter and setter methods here}publicclass Fire { private Room room;
// getter and setter methods here}publicclass Alarm {}
Model is multiplefacts and theirrelationships
8/2/2019 Drools Gateway Jug
31/107
Fact Model Example
publicclass Room { private String name // getter and setter methods here}publicclass Sprinkler {
private Room room; privatebooleanon; // getter and setter methods here}publicclass Fire { private Room room;
// getter and setter methods here}publicclass Alarm {}
Must have setters/getters
Must have a publicno-arg constructor
No mandatoryinheritance/interface
Model is multiplefacts and theirrelationships
8/2/2019 Drools Gateway Jug
32/107
Rules
8/2/2019 Drools Gateway Jug
33/107
Rules
Form the IF/Then action defined as When/Then
8/2/2019 Drools Gateway Jug
34/107
Rules
Form the IF/Then action defined as When/Then Must have a name that is unique for a rule
package
8/2/2019 Drools Gateway Jug
35/107
Rules
Form the IF/Then action defined as When/Then Must have a name that is unique for a rule
package
LHS (Left Hand Side)
Conditional part of the rule
Evaluate fact attributes based on criteria
8/2/2019 Drools Gateway Jug
36/107
Rules
Form the IF/Then action defined as When/Then Must have a name that is unique for a rule
package
LHS (Left Hand Side)
Conditional part of the rule
Evaluate fact attributes based on criteria
RHS (Right Hand Side)
Consequence or action part of the rule Invoke operations
Modify Fact State
8/2/2019 Drools Gateway Jug
37/107
Rules
Form the IF/Then action defined as When/Then Must have a name that is unique for a rule
package
LHS (Left Hand Side)
Conditional part of the rule
Evaluate fact attributes based on criteria
RHS (Right Hand Side)
Consequence or action part of the rule Invoke operations
Modify Fact State
8/2/2019 Drools Gateway Jug
38/107
Rules
Form the IF/Then action defined as When/Then Must have a name that is unique for a rule
package
LHS (Left Hand Side)
Conditional part of the rule
Evaluate fact attributes based on criteria
RHS (Right Hand Side)
Consequence or action part of the rule Invoke operations
Modify Fact State
8/2/2019 Drools Gateway Jug
39/107
Rules
Form the IF/Then action defined as When/Then Must have a name that is unique for a rule
package
LHS (Left Hand Side)
Conditional part of the rule
Evaluate fact attributes based on criteria
RHS (Right Hand Side)
Consequence or action part of the rule Invoke operations
Modify Fact State
Rules can be authored in multiple ways!
8/2/2019 Drools Gateway Jug
40/107
Rules in DRLpackage com.sample
import com.sample.*;
rule"When there is a fire turn on the sprinkler"dialect"mvel"when Fire( $room: room) $sprinkler: Sprinkler( room == $room, on == false )then modify ($sprinkler) {on = true}; println("Sprinkler activated in " + $room.name);end
rule"When the fire is gone turn off the sprinkler"dialect"mvel"when
$room : Room()
$sprinkler : Sprinkler( room == $room, on == true ) not Fire( room == $room )then modify( $sprinkler ) { on = false };
println( "Turn off the sprinkler for room " + $room.name );end
8/2/2019 Drools Gateway Jug
41/107
Conditional Elements
and all attributes match (default of comma separated list)
or either attribute matches
eval catch all element
wraps any primative returning semantic code
not attribute does not match
exists checks for the existence of something
collect, memberOf, accumulate elements to reason over collections of data
from element to retreive data from external sources like DBs, WebServices,
etc.
matches, soundslike, regular expressions and English language phonetics
8/2/2019 Drools Gateway Jug
42/107
Rule Control
no-loop short circuit rule recursion
salience numeric value that represents rule importance
agenda-group fire rules in group only when in focus
auto-focus trigger focus change to the rule's agenda-group
activation-group first matching rule fires
all other rules in group are ignored lock-on-active
date-effective, date-expires define rules that are only active at certain points in time
template define templates that may be reused in multiple rules
8/2/2019 Drools Gateway Jug
43/107
- Dynamic Facts- Decision Tables- Guided Rules- English/Industry Specific Rules- Guided Tests- Scenario Tests- Asset Search- Browse by Category- Browse by Status
- Spreadsheet Decision Tables
- Technical Rules (.drl)- Enumerations- Domain Specific Language- Templates- Rule Flow- Step-debugging- Agenda Views and Inspection- Working Memory Inspection- Rule Engine Audit Trails- Technical Tests- Technical Test Suites
Web Broswer
Spread sheet
JBoss Developer Studio
Avenues for Authoring Rules
8/2/2019 Drools Gateway Jug
44/107
20
BRMS Rich UI for Business Rules
8/2/2019 Drools Gateway Jug
45/107
21
Fact Model Editor
8/2/2019 Drools Gateway Jug
46/107
22
Guided Rule Editor (Web)
8/2/2019 Drools Gateway Jug
47/107
23
Web Decision Table Editor
8/2/2019 Drools Gateway Jug
48/107
24
Decision Tables
8/2/2019 Drools Gateway Jug
49/107
Discussions & Inbox
8/2/2019 Drools Gateway Jug
50/107
DroolsDoc
Si l A t V ifi ti
8/2/2019 Drools Gateway Jug
51/107
Single Asset Verification
8/2/2019 Drools Gateway Jug
52/107
Multiple View / Edits in a Single Tab
F C ll t & A l t S t
8/2/2019 Drools Gateway Jug
53/107
From, Collect & Accumulate Support
From CE
From Collect CE
From Accumulate CE
8/2/2019 Drools Gateway Jug
54/107
Rule Template Support
W ki S t
8/2/2019 Drools Gateway Jug
55/107
Workin Sets
8/2/2019 Drools Gateway Jug
56/107
Fact Constraints within WorkingSets
8/2/2019 Drools Gateway Jug
57/107
Runtime
8/2/2019 Drools Gateway Jug
58/107
Runtime: Buildinprivatestatic KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("fire.drl"),ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors(); if (errors.size() > 0) { for (KnowledgeBuilderError error: errors) { System.err.println(error); } thrownew IllegalArgumentException("Could not parse knowledge."); }
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
8/2/2019 Drools Gateway Jug
59/107
Runtime: Buildinprivatestatic KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("fire.drl"),ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors(); if (errors.size() > 0) { for (KnowledgeBuilderError error: errors) { System.err.println(error); } thrownew IllegalArgumentException("Could not parse knowledge."); }
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
8/2/2019 Drools Gateway Jug
60/107
Runtime: Buildinprivatestatic KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("fire.drl"),ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors(); if (errors.size() > 0) { for (KnowledgeBuilderError error: errors) { System.err.println(error); } thrownew IllegalArgumentException("Could not parse knowledge."); }
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
8/2/2019 Drools Gateway Jug
61/107
Runtime: Buildinprivatestatic KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("fire.drl"),ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors(); if (errors.size() > 0) { for (KnowledgeBuilderError error: errors) { System.err.println(error); } thrownew IllegalArgumentException("Could not parse knowledge."); }
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
8/2/2019 Drools Gateway Jug
62/107
Runtime: Buildinprivatestatic KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("fire.drl"),ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors(); if (errors.size() > 0) { for (KnowledgeBuilderError error: errors) { System.err.println(error); } thrownew IllegalArgumentException("Could not parse knowledge."); }
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
C l S i C fi ti
8/2/2019 Drools Gateway Jug
63/107
Camel & Spring Configuration
THE BRE now has extensive Spring support, the XSDcan be found in the the drools-spring jar. The
namespace is "http://drools.org/schema/drools-spring"
R ti E ti
http://www.springframework.org/schema/beanshttp://www.w3.org/2001/XMLSchema-instancehttp://drools.org/schema/drools-springhttp://drools.org/schema/drools-springhttp://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsdhttp://drools.org/schema/drools-springhttp://drools.org/schema/drools-springhttp://drools.org/schema/drools-springhttp://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsdhttp://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsdhttp://drools.org/schema/drools-springhttp://drools.org/schema/drools-springhttp://drools.org/schema/drools-springhttp://drools.org/schema/drools-springhttp://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2001/XMLSchema-instancehttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans8/2/2019 Drools Gateway Jug
64/107
Runtime - Execution try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
for( String name: ROOM_NAMES ){ Room room = new Room( name ); name2room.put( name, room ); ksession.insert( room ); Sprinkler sprinkler = new Sprinkler( room ); ksession.insert( sprinkler ); } // go ! ksession.fireAllRules();
R ti E ti
8/2/2019 Drools Gateway Jug
65/107
Runtime - Execution try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
for( String name: ROOM_NAMES ){ Room room = new Room( name ); name2room.put( name, room ); ksession.insert( room ); Sprinkler sprinkler = new Sprinkler( room ); ksession.insert( sprinkler ); } // go ! ksession.fireAllRules();
R ti E ti
8/2/2019 Drools Gateway Jug
66/107
Runtime - Execution try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
for( String name: ROOM_NAMES ){ Room room = new Room( name ); name2room.put( name, room ); ksession.insert( room ); Sprinkler sprinkler = new Sprinkler( room ); ksession.insert( sprinkler ); } // go ! ksession.fireAllRules();
R ti E ti
8/2/2019 Drools Gateway Jug
67/107
Runtime - Execution try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
for( String name: ROOM_NAMES ){ Room room = new Room( name ); name2room.put( name, room ); ksession.insert( room ); Sprinkler sprinkler = new Sprinkler( room ); ksession.insert( sprinkler ); } // go ! ksession.fireAllRules();
R ti E ti
8/2/2019 Drools Gateway Jug
68/107
Runtime - Execution try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
for( String name: ROOM_NAMES ){ Room room = new Room( name ); name2room.put( name, room ); ksession.insert( room ); Sprinkler sprinkler = new Sprinkler( room ); ksession.insert( sprinkler ); } // go ! ksession.fireAllRules();
R ti E ti
8/2/2019 Drools Gateway Jug
69/107
Runtime - Execution try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
for( String name: ROOM_NAMES ){ Room room = new Room( name ); name2room.put( name, room ); ksession.insert( room ); Sprinkler sprinkler = new Sprinkler( room ); ksession.insert( sprinkler ); } // go ! ksession.fireAllRules();
R ti E ti
8/2/2019 Drools Gateway Jug
70/107
Runtime - Execution try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
for( String name: ROOM_NAMES ){ Room room = new Room( name ); name2room.put( name, room ); ksession.insert( room ); Sprinkler sprinkler = new Sprinkler( room ); ksession.insert( sprinkler ); } // go ! ksession.fireAllRules();
> Everything is OK
i i
8/2/2019 Drools Gateway Jug
71/107
Runtime - Execution Fire kitchenFire = new Fire( name2room.get( "kitchen" ) ); Fire officeFire = new Fire( name2room.get( "office" ) ); FactHandle kitchenFireHandle = ksession.insert( kitchenFire ); FactHandle officeFireHandle = ksession.insert( officeFire ); ksession.fireAllRules();
ti ti
8/2/2019 Drools Gateway Jug
72/107
Runtime - Execution Fire kitchenFire = new Fire( name2room.get( "kitchen" ) ); Fire officeFire = new Fire( name2room.get( "office" ) ); FactHandle kitchenFireHandle = ksession.insert( kitchenFire ); FactHandle officeFireHandle = ksession.insert( officeFire ); ksession.fireAllRules();
> Raise the alarm> Turn on the sprinkler for room kitchen
> Turn on the sprinkler for room office
R ti E ti
8/2/2019 Drools Gateway Jug
73/107
Runtime - Execution ksession.retract( kitchenFireHandle ); ksession.retract( officeFireHandle ); ksession.fireAllRules();
R ti E ti
8/2/2019 Drools Gateway Jug
74/107
Runtime - Execution ksession.retract( kitchenFireHandle ); ksession.retract( officeFireHandle ); ksession.fireAllRules();
> Turn off the sprinkler for room office> Turn off the sprinkler for room kitchen> Cancel the alarm
> Everything is ok
8/2/2019 Drools Gateway Jug
75/107
Use FROM for external data
rule Find Vehicles for a given zip code"when
$zipCode : ZipCode() Vehicle() from $hibernate.getNamedQuery( FindVehicles )
.setParameters( [ zipCode : $zipCode ]) .list()then...
end
Can be a Web Service, Hibernate or any external system
R ti Vi ibilit JMX
8/2/2019 Drools Gateway Jug
76/107
Runtime Visibility - JMX
Drools 5.3 brings support to the JMX standard andenables knowledge base and knowledge sessionmonitoring and inspection using any JMX console.
KnowledgeBase Stats
Runtime Visibility JMX
8/2/2019 Drools Gateway Jug
77/107
Runtime Visibility - JMX
KnowledgeSession Stats
Deployment
- PackagingSnapshots - Asset Search
8/2/2019 Drools Gateway Jug
78/107
Facts
Rules
Tests
Analysis
Java Jars Dynamic Facts
- Technical Rules (.drl)- Enumerations- Domain Specific Language- Templates- Rule Flow
- Decision Tables- Guided Rules- English/Industry Specific Rules
- Decision Tables
- Technical Tests- Technical Test Suites
- Guided Tests- Scenario Tests
- Step-debugging- Agenda Views and Inspection- Working Memory Inspection- Rule Engine Audit Trails
- Rule Authoring Analysis- Guided Test Audit Trails
- Snapshots- Status Definition- User Administration- Categorization
Developer-centric Business Analyst
Asset Search- Browse by Category- Browse by Status
Web-only Feature
Modifiable via Web Browser or Developer IDE
Modifiable via Developer IDE
Modifiable via Excel/OpenOffice
Deployment
- PackagingSnapshots - Asset Search
8/2/2019 Drools Gateway Jug
79/107
Facts
Rules
Tests
Analysis
Java Jars Dynamic Facts
- Technical Rules (.drl)- Enumerations- Domain Specific Language- Templates- Rule Flow
- Decision Tables- Guided Rules- English/Industry Specific Rules
- Decision Tables
- Technical Tests- Technical Test Suites
- Guided Tests- Scenario Tests
- Step-debugging- Agenda Views and Inspection- Working Memory Inspection- Rule Engine Audit Trails
- Rule Authoring Analysis- Guided Test Audit Trails
- Snapshots- Status Definition- User Administration- Categorization
Developer-centric Business Analyst
- Browse by Category- Browse by Status
Web-only Feature
Modifiable via Web Browser or Developer IDE
Modifiable via Developer IDE
Modifiable via Excel/OpenOffice
Deployment
- Packaging- Snapshots - Asset Search
8/2/2019 Drools Gateway Jug
80/107
Facts
Rules
Tests
Analysis
Java Jars Dynamic Facts
- Technical Rules (.drl)- Enumerations- Domain Specific Language- Templates- Rule Flow
- Decision Tables- Guided Rules- English/Industry Specific Rules
- Decision Tables
- Technical Tests- Technical Test Suites
- Guided Tests- Scenario Tests
- Step-debugging- Agenda Views and Inspection- Working Memory Inspection- Rule Engine Audit Trails
- Rule Authoring Analysis- Guided Test Audit Trails
- Snapshots- Status Definition- User Administration- Categorization
Developer-centric Business Analyst
- Browse by Category- Browse by Status
Web-only Feature
Modifiable via Web Browser or Developer IDE
Modifiable via Developer IDE
Modifiable via Excel/OpenOffice
Eclipse Developer Perspective
8/2/2019 Drools Gateway Jug
81/107
43
Eclipse Developer Perspective
Debugging
8/2/2019 Drools Gateway Jug
82/107
44
Debugging
Debug Views
l
New rule perspective to configure IDE for rules as needed
Guided Rule Editor (Eclipse)
8/2/2019 Drools Gateway Jug
83/107
45
Guided Rule Editor (Eclipse)
Eclipse Guided Editor
Rule Flow
8/2/2019 Drools Gateway Jug
84/107
46
Rule Flow
N d T
8/2/2019 Drools Gateway Jug
85/107
Node Types
8/2/2019 Drools Gateway Jug
86/107
Domain Specific Process Steps
Extend Drools Flow to incorporateyour applications needs
Note: Community Only
Integrated Tooling
8/2/2019 Drools Gateway Jug
87/107
Integrated Tooling
CEP
8/2/2019 Drools Gateway Jug
88/107
CEP
Complex event processing
Real time events (concurrent events threadsafe):
sliding windows:Pattern(...) over window:time(3000)
Fusion Enables:
8/2/2019 Drools Gateway Jug
89/107
Fusion Enables:
Event Detection:
From an event cloud or set of streams, select all themeaningful 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 eventsAND reason over them
Events
8/2/2019 Drools Gateway Jug
90/107
Events
(Usually) Immutable FactsStrong Temporal
Relationship
Managed LifecylceUse of sliding windows
Can provide metadata on:
@timestamp, @duration or@expires
Streams
8/2/2019 Drools Gateway Jug
91/107
Streams
Temporal Reasoning
8/2/2019 Drools Gateway Jug
92/107
Temporal Reasoning
Event and Time semantics:
Point in Time
Over an Interval
Unified semantics for eventcorrelation over time
Temporal Constraints:
Set of 13 operators to express
temporal relationship between
events
Expressive Event Constraints
8/2/2019 Drools Gateway Jug
93/107
Expressive Event Constraints
Point-Point Point-Interval Interval-Interval
A beforeB
A meets B
A overlaps B
A includes B
A finishes B
A starts B
A coincides B
Behaviors & Sliding Windows
8/2/2019 Drools Gateway Jug
94/107
Behaviors & Sliding Windows
Behaviors: special semantics to certain patterns sliding windows, distinct, sort, etc
SlidingWindow: Allows reasoning over a movingwindow of interest
Time
Length
Memory Management
8/2/2019 Drools Gateway Jug
95/107
Memory Management
CEP scenarios are stateful by nature.
Events usually are only interesting
during a short period of time.Fusion manages the benefits
memory management while events
still in window of consideration
Rulebase Partitioning
8/2/2019 Drools Gateway Jug
96/107
Rulebase Partitioning
Achieves coarsegrainedparallelization
No fundamentalchanges in thematching algorithm
(ReteOO)
Preservesoptimizations,especially node
sharing
8/2/2019 Drools Gateway Jug
97/107
Planner
Wh t i Pl ?
8/2/2019 Drools Gateway Jug
98/107
What is Planner?
Optimizes Automated Planning
Use Cases:
Space Planning Employee Shift Rostering
Team Scheduling
Still in development! Not commercially supported.
8/2/2019 Drools Gateway Jug
99/107
Hospital Admissions
Patient Admission Schedule
8/2/2019 Drools Gateway Jug
100/107
Patient Admission Schedule
Hard constraints No 2 patients in same bed in same night
Room gender limitation
Department minimum or maximum age
Patient requires specific room equipment(s)
Soft constraints Patient prefers maximum room size
Department specialization
Room specialization Patient prefers specific room equipment(s)
Pl S t
8/2/2019 Drools Gateway Jug
101/107
Planner Syntax// If a hospital patient prefers specific equipment, try to assign him/her a hospital
room with such equipment.rule"preferredPatientEquipment"
when // If a patient prefers specific equipment
PreferredPatientEquipment($patient : patient, $equipment : equipment);
// and that patient is assigned a roomBedDesignation(patient == $patient, $room : room);
// and that room doesn't have that equipment
not RoomEquipment(room == $room, equipment == $equipment); then
... // lower the score with a certain weightend
Needle in a Haystack
8/2/2019 Drools Gateway Jug
102/107
Needle in a Haystack
Needle in a Haystack
8/2/2019 Drools Gateway Jug
103/107
Needle in a Haystack
How many possiblesolutions? 310 beds
in 105 rooms
in 4 departments 84 nights
Needle in a Haystack
8/2/2019 Drools Gateway Jug
104/107
Needle in a Haystack
How many possiblesolutions? 310 beds
in 105 rooms
in 4 departments 84 nights
2750 patients(admissions)
Needle in a Haystack
8/2/2019 Drools Gateway Jug
105/107
Needle in a Haystack
How many possiblesolutions? 310 beds
in 105 rooms
in 4 departments 84 nights
2750 patients(admissions)
Numbers from a realdataset
Commercial Support
8/2/2019 Drools Gateway Jug
106/107
Commercial Support
Drools ships within several supportedplatforms:
JBoss Enterprise BRMS
JBoss Enterprise SOA Platform *
JBoss Enterprise Application Platform **
Support Open Source!
8/2/2019 Drools Gateway Jug
107/107
Support Open Source!
We need You! JBoss User Groups
Contribute
Code Features
Documentation
Testing
Let us continue our work that benefits so many.