●
The SkyNet funding bill is passed.
●
The system goes online on August 4th, 1997.
●
Human decisions are removed from strategic defense.
●
SkyNet begins to learn at a geometric rate.
●
It becomes self-aware at 2:14am Eastern time, August
29th
●
In a panic, they try to pull the plug.
●
And, Skynet fights back
Mark Proctor
Co-Creator
Project Lead
2
Topics
 What's new in 5.1
 Drools and OSS Community
 History
 Unified Vision
 Expert
 Fusion
 Flow
What's new
In 5.1
4
What's new to 5.1
 Integration
● OSGi ready
● Spring
● Camel
● JMX/JOPR integration
 Expert
● New Rete Algorithm “differential update”
● Timers and Calendars
● Live Open Querries
●
 Flow
● BPMN2
5
Differential Update
 Differential Update (a.k.a. “true modify”)
● Implements a real “modify/update” operation, instead of
retract+assert.
● Reuses tuples, reduces GC stress, improves performance
6
What's new to 5.1
 Guvnor
● Guided editor
● Nested Expression builder
● person.dogs[0].name
● Move constrains up and down
● Insert constraints
● Support for more DRL elements
● RSS Subcription, change notifications, inbox
● Working Sets
● Object constraint definitions
● Rule Templates (based on Guided Editor)
● Oryx BPM editor integration
● Better rule documentation support
7
Drools flow in Oryx
8
Drools flow in Eclipse
Community
10
Books
11
Boot Camps
 San Francisco 2009 (40+ attendees)
● Sponsored by Third Pillar
● Sun, FAMC, OSDE, Kaseya, Fedex, TU Group, Intermountain
Healthcare, Gap, Sony Pictures, Lockheed Martin, Kaiser, HP,
Wells Fargo, US Navy Research, FOLIOfn, Boeing .....
 San Diego 2010 (80+ attendess)
● Sponsored by US Navy
● 5 day event, with 2 days focus on the healthcare industry
● OSDE, AT&T, SAIC, US Navy Research, Kaiser, Clinica,
Intermountain Healthcare, GE Healthcare, VA, Boeing,
Nationwide ....
12
Boot Camps
 Rules Fest 11th
October
● 3 day conferene + 1 day boot camp
 USA and EMA in Febuary, watch blog for news
● http://blog.athico.com
13
Community Collaboration
 40% of Drools work now done in the community
● US Navy Healthcare
● OSDE (Argentina's largest healthcare organisation)
● Intalio
14
Sample Industries and Users
 Investment
● Millennium Investment Group (MIG)
 Logistics
● Fedex
 Airline
● Sabre
 Mortgage
● Franklin American
 Healthcare
● OSDE
History
16
It All Started Here
Birth of CDSS
Dendral
Baobab
Mycin
Guidon
Neomycin
Teiresias
Puff
Emycin
WM
Sacon
Centaur
Wheeze
Gravida
Clot
Oncocin
1970s
1980s
17
Because Not Everyone
Is As Smart As He Is
18
Business Rules Engines
OPS5
ART
Clips
Jess
Drools 2
JRules
1980s
2010s
Drools 3
1990s
2000s
Drools 4
Drools 5
19
Drools History
 Drools 2
● Rete “like” XML Scripting language
 Drools 3
● Based on Clips functionality
● Iterative improves to JRules syntax with Clips functionality
 Drools 4
● More declarative
● Basic functional programming feature with “from”
● Basic Rule Flow
● Basic BRMS
 Drools 5
● Improved functional programming with 'accumulate'
● More Advanced Rule Flow integration
● Complex Event Process (Fusion)
● Temporal Comparators, Sliding Time Windows
● Production ready BRMS
Unified Vision
21
Drools Modules
Business Logic integration System
Drools
Guvnor
Drools
Fusion
Drools
Flow
(jBPM5)
Drools
Expert
22
Drools Modules
Drools
Grid
Drools
Planner
Drools
Semantics
Drools
Chance
Business Logic integration System
23
Business Logic Lifecycle
24
Rules and processes
loosely coupledtightly coupled
specificgeneric
Decision
Services
Process
Rules
SCOPE
COUPLING
?
25
Event Driven Architectures
edBPM + EDM
26
Domain Overview
27
Domain Overview
28
Hybrid Logic Engine
 Production Rule Systems PRD (forward chaining)
● Reactive
● when Alarm( status == “alert” )
then send( “warning” )
 Logic Programming LP (backward chaining)
● Query
● descendant( “mary”, “jane”)
 Functional Programming FP
● Map,Fold, Filter
● avg([12, 16, 4, 6])
● Returns single value 9.5
● round([10.3, 4.7, 7.8] )
● Returns List [10, 5, 8]
 Description Logic
● Person hasName String and
livesAt Address
29
 Production Rule Systems PRD (forward chaining FC)
● Drools 5.0, OPSJ ( hyrbid BC), ART( hyrbid BC)
 Logic Programming LP (backward chaining BC)
● target : Prolog (POSL Position Slotted Language)
● Drools Trunk has a prototype Prolog like query backward
chaining capabilities. Stronger Polog like capabilities planned.
● Opportunistic BC planned.
 Functional Programming FP
● Lisp, Haskell
● Drools 5.0 has some functional capabilities
● Drools 5.1, 5.2 will be looking to have strong functional
capabilities
Hybrid Logic Engine
30
 Description Logic DL
● KIF, OWL-DL
● Planned, See “The Future”
Hybrid Logic Engine
31
The Future
 Full Hybrid Engine
● http://community.jboss.org/wiki/DroolsLanguageEnhancements
●Nested Objects
●Casting Nested Objects
●Positional Constraints
●POSL - Positional-Slotted
Language
●Method Calls
●Maps and Arrays
(Collections)
●Collections and XPath like
filtering
●Free form Expressions
●Managed Object Graphs
(MOGS)
●Nested Patterns and Queries
●Queries and Unification
●Ontologies and Relations via
●Query Based Backward
Chaining with POSL
●Triples with Hybrid POJO Graph
Notation.
●Escapes for Dialects
●Accumulate Improvements to
Support Haskell map/fold/filter
and MVEL projection/fold
● Otherwise
● Branch (Labelled Else)
● Rule Execution Groups
● Rule Dependency Meta-Rule
Language
●Parallel Meta-Rule Language
● Field Versioning
●Logical Closures/OnFalse
●Opportunistic Backward
Chaining, Lazy Field/Object
Values
●...
32
Achieving More
By Doing Less
33
jBPM
File file = new File (“.....”); // file to XML process definition
ProcessDefinition processDefinition =
ProcessDefinition.parseXmlString( IoUtils.FileToString( file ) );
ProcessInstance processInstance =
new ProcessInstance(processDefinition);
Jess
Rete engine = new Rete();
FileReader file = new FileReader("myfile.clp");
Jesp parser = new Jesp(file, engine);
parser.parse(false);
Esper
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
EPStatement countStmt = admin.createEPL( "...." );
countStmt.start();
Knowledge API
34
Drools Flow
KnowledegBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBulider();
kbuilder.addResource(
ResourceFactory.newClassPathResource( “myflow.bpmn2”,
ResourceType.BPMN2 );
If ( kbuilder.hasErrors() ) {
log.error( kbuilder.hasErrors().toString() );
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbase.getKnowledgePackages() );
Knowledge API
35
Drools Expert
KnowledegBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBulider();
kbuilder.addResource(
ResourceFactory.newClassPathResource( “myrules.drl”,
ResourceType.DRL );
If ( kbuilder.hasErrors() ) {
log.error( kbuilder.hasErrors().toString() );
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbase.getKnowledgePackages() );
Knowledge API
36
Drools Integration Deployment Descriptors
<change-set>
<add>
<resource source='classpath:myapp/data/myflow.bpmn2' type='BPMN2' />
<resource source='http:myapp/data/myrules.drl' type='DRL' />
<resource source='classpath:data/IntegrationExampleTest.xls'
type="DTABLE">
<decisiontable-conf input-type="XLS"
worksheet-name="Tables_2" />
</resource>
<add>
</change-set>
KnowledegBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBulider();
kbuilder.addResource(
ResourceFactory.newFileResource( “changeset.xml”,
ResourceType.ChangeSet );
Knowledge XML
37
<drools:kbase id="kbase1">
<drools:resource type="DRL"
source="classpath:.../testSpring.drl"/>
</drools:kbase>
<drools:ksession id="ksession1" type="stateless" kbase="kbase1" />
<drools:ksession id="ksession2" type="stateful" kbase="kbase1"/>
<camelContext id="camel">
<route>
<from uri="cxfrs://bean://rsServer"/>
<marshal ref="xstream"/>
<to uri=”drools:ksession1” />
<unmarshal ref="xstream"/>
</route>
</camelContext>
Declarative Services
Spring XML and Camel
39
Integrated debug and audit
40
Simulation Testing
Drools Expert
42
D a te d a te
d o u b le a m o u n t
in t ty p e
lo n g a c c o u n tN o
C a s h flo w
lo n g a c c o u n tN o
d o u b le b a la n c e
A c c o u n t
D a te s ta r t
D a te e n d
A c c o u n tin g P e r io d
Classes
43
rule “increase balance for AccountPeriod Credits”
when
ap : AccountPeriod()
acc : Account( $accountNo : accountNo )
CashFlow( type == CREDIT,
accountNo == $accountNo,
date >= ap.start && <= ap.end,
$ammount : ammount )
then
acc.balance += $amount;
end
select * from Account acc,
Cashflow cf, AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == CREDIT
cf.date >= ap.start and
cf.date <= ap.end
trigger : acc.balance += cf.amount
Credit Cashflow Rule
44
rule “increase balance for AccountPeriod
Credits”
when
ap : AccountPeriod()
acc : Account( $accountNo : accountNo )
CashFlow( type == CREDIT,
accountNo == $accountNo,
date >= ap.start && <= ap.end,
$ammount : ammount )
then
acc.balance += $amount;
end
rule “decrease balance for AccountPeriod
Debits”
when
ap : AccountPeriod()
acc : Account( $accountNo : accountNo )
CashFlow( type == DEBIT,
accountNo == $accountNo,
date >= ap.start && <= ap.end,
$ammount : ammount )
then
acc.balance -= $amount;
end
Rules as a “view”
date amount type
12-Jan-07 100 CREDIT 1
2-Feb-07 200 DEBIT 1
18-May-07 50 CREDIT 1
9-Mar-07 75 CREDIT 1
CashFlow
accountNo
CashFlow
date amount type
12-Jan-07 100 CREDIT
9-Mar-07 75 CREDIT
CashFlow
date amount type
2-Feb-07 200 DEBIT
AccountingPeriod
start end
01-Jan-07 31-Mar-07
Account
accountNo balance
1 0
Account
accountNo balance
1 -25
Conditional
Elements
46
not Bus( color = “red” )
Conditional Elements
exists Bus( color = “red” )
forall ( $bus : Bus( floors == 2 )
Bus( this == $bus, color == “red” ) )
forall ( $bus : Bus( color == “red” ) )
47
Accumulate CE
rule "accumulate"
when
acc( Bus( color == "red", $t : takings );
$min : min( $t ), $max : max( $t );
$min > 100 && $max < 200 )
then
println( "range is “ + $min + “ “ + $max );
end
48
Accumulate CE
Patterns and CE's can be chained with 'from'
rule "collect"
when
$zipCode : ZipCode()
acc( Bus( color == "red", $t : takings )
from $hbn.getNamedQuery(“Find Buses”)
.setParameters( [ “zipCode” :
$zipCode ] ).list();
$sum : sum( $t );
$sum > 100 )
then
print "sum is “ + $sum;
end
Live Queries
50
Live Queries
query (String $region, int $min, int $max ) {
$c : Cheese( region == $region, price > $min && price < $max )
exists( StockItem( type == $c )
}
ViewChangedEventListener listener =
new ViewChangedEventListener() {
public void rowUpdated(Row row) {
println( "updated" + row.get( "$c" ) );
}
public void rowRemoved(Row row) {
println( "removed" + row.get( "$c" ) );
}
public void rowAdded(Row row) {
println( "added" + row.get( "$c" ) );
}
};
51
Live Queries
LiveQuery query = ksession.openLiveQuery( "cheeses",
new Object[] { "devon", 10, 50 },
listener );
...
...
query.dispose()
Timers
Calendars
53
Timers
rule “name”
timer (int: 1m30s 0)
when
$l : Light( status == “on” )
then
modify( $l ) { status = “off” };
When the light is on, and has been
on for 1m30s then turn it off
54
Timers
rule “name”
timer ( cron: 0 0/15 * * * * )
when
Alarm( )
then
sendEmail( ”Alert Alert Alert!!!” )
Field Name Mandatory? Allowed Values Allowed Special Characters
Seconds YES 0-59 , - * /
Minutes YES 0-59 , - * /
Hours YES 0-23 , - * /
Day of month YES 1-31 , - * ? / L W
Month YES 1-12 or JAN-DEC , - * /
Day of week YES 1-7 or SUN-SAT , - * ? / L #
Year NO empty, 1970-2099 , - * /
Send alert every quarter of an hour
55
Calendars
rule "weekdays are high priority"
calendars "weekday"
timer (int:0 1h)
when
Alarm()
then
send( "priority high - we have an alarm” );
end
rule "weekend are low priority"
calendars "weekend"
timer (int:0 4h)
when
Alarm()
then
send( "priority low - we have an alarm” );
end
Execute now and after
1 hour duration
Execute now and after
4 hour duration
Drools Expert
Authoring Metaphores
57
Guided Editor
58
Decision Table
59
Decision Table
rule "Pricing bracket_10"
when
Driver(age >= 18, age <= 24,
locationRiskProfile == "LOW",
priorClaims == "1")
policy:
Policy(type == "COMPREHENSIVE")
then
policy.setBasePrice(450);
Fusion
61
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 Sequencing:
● A → ( B OR C ) → D
 Event Abstraction:
● Ability to compose complex events from atomic events AND
reason over them
62
Drools Fusion: Features
 Support to Event semantics:
● Usually immutable, but not enforced
● Strong temporal relationships
● Managed lifecycle
● Point-in-time and Interval events
 Time semantics
● Discrete
 Temporal relationships
● All 13 operators defined by James Allen (+ negations)
63
Drools Fusion: Temporal Reasoning
P o i n t - P o i n t P o i n t - I n t e r v a l I n t e r v a l - I n t e r v a l
A b e f o r e B
A m e e t s B
A o v e r la p s B
A f in is h e s B
A in c lu d e s B
A s t a r t s B
A c o in c id e s B
A
B
A
B
A
B
A
B
A
B
A
B
A
B
64
Drools Fusion: Temporal Reasoning
P o i n t - P o i n t P o i n t - I n t e r v a l I n t e r v a l - I n t e r v a l
A a f t e r B
A m e t B y B
A o v e r la p e d B y B
A f in is h e d B y B
A d u r in g B
A f in is h e s B
A
B
A
B
A
B
A
B
A
B
A
B
65
$c : Custumer( type == “VIP )
$oe : BuyOrderEvent( customer == $c )
from entry-point “Home Broker Stream”
not BuyAckEvent( relatedEvent == $oe.id, this after[1s, 10s] $oe )
from entry-point “Stock Trader Stream”
Operators
Existing Drools 'not'
Conditional Elements can
be used to detect non-
occurrence of events
BackAckEvent must occur
between 1s and 10s 'after'
BuyOrderEvent
66
Aggregations
Rule Engines do not deal with aggregations
acc( $s : StockTicker( symbol == “RHAT” ) over window:time( 5s );
$avg : avg( $s.price );
$avg > 100 )
Over 5 seconds
Aggregate ticker price
for RHAT over last 5
seconds
67
CEP Applied at FedEx Custom
Critical
 Time specific deliveries for critical freight
 Exclusive use non-stop door-to-door services
 Blended Surface and Air services to minimize cost and transit
time
 Extra care in handling and specially equipped vehicles
● Temperature Control, Secured Services, Hazardous Material, Constant
Surveillance
* Presented by Adam Mollemkopf at ORF 2009
68
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
69
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
70
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
71
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
72
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
73
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
74
 At least 50% of Alerts can be reasoned automatically, promoting
staff savings and improved Customer and Driver experiences.
 Risk Avoidance via pro-active monitoring
● Reduction in insurance claims and shipment service failures
 Minimum 30% efficiency gains in shipment monitoring , saving
at least 15% of Operations staff cost.
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
75
 Some numbers (from early 2010):
● 24 x 7 sessions, no downtime
● Average of 500k+ facts/events concurrently in memory
● Business hours: 1M+ facts/events concurrently
● Response time for reasoning cycles:
● Average: 150 ms
● Peak: 1.2 sec
● Several hundred rules
CEP Applied at FedEx Custom
Critical * Presented by Adam Mollemkopf at ORF 2009
Drools Flow
(jBPM5)
77
BPMN 2.0
 OMG Standard that defines
● Graphical notation
● Process definition format (XSD/XMI)
● Execution Semantics
 Extensible
 Interoperability
 http://www.omg.org/spec/BPMN/2.0
78
Palette
 Predefined set of generic node types
● start, end
● Gateway
● Script
● Sub-process
● Event
● ...
79
Drools flow in Eclipse
80
Drools flow in Oryx
81
Process Debugging
82
Domain-Specific Processes
83
Domain-Specific Processes
 Other Examples
● Email / notifications
● File management: archive, find, copy
● FTP, RSS, Jabber, Rest
● ESB
● Google Calendar, social websites
 Library
84
Non Linear Processes
85
Rules and Process
86
Events and Processes
declare ProcessStartedEvent
@role( event )
end
rule "Number of process instances above threshold" when
acc( e: ProcessStartedEvent(
processId == "com.sample.order.OrderProcess" )
over window:size(1h),
$c : count(e),
$c > 1000)
then
System.err.println( "WARNING: Nb of order processes in the last
hour > 1000: " + nbProcesses );
end
87
Human Tasks - WS-HT
88
Questions?Questions?
• Dave Bowman: All right, HAL; I'll go in
through the emergency airlock.
• HAL: Without your space helmet, Dave,
you're going to find that rather difficult.
• Dave Bowman: HAL, I won't argue with
you anymore! Open the doors!
• HAL: Dave, this conversation can serve
no purpose anymore. Goodbye.
Joshua: Greetings, Professor Falken.
Stephen Falken: Hello, Joshua.
Joshua: A strange game. The only
winning move is not to play. How
about a nice game of chess?

Drooling for drools (JBoss webex)

  • 1.
    ● The SkyNet fundingbill is passed. ● The system goes online on August 4th, 1997. ● Human decisions are removed from strategic defense. ● SkyNet begins to learn at a geometric rate. ● It becomes self-aware at 2:14am Eastern time, August 29th ● In a panic, they try to pull the plug. ● And, Skynet fights back Mark Proctor Co-Creator Project Lead
  • 2.
    2 Topics  What's newin 5.1  Drools and OSS Community  History  Unified Vision  Expert  Fusion  Flow
  • 3.
  • 4.
    4 What's new to5.1  Integration ● OSGi ready ● Spring ● Camel ● JMX/JOPR integration  Expert ● New Rete Algorithm “differential update” ● Timers and Calendars ● Live Open Querries ●  Flow ● BPMN2
  • 5.
    5 Differential Update  DifferentialUpdate (a.k.a. “true modify”) ● Implements a real “modify/update” operation, instead of retract+assert. ● Reuses tuples, reduces GC stress, improves performance
  • 6.
    6 What's new to5.1  Guvnor ● Guided editor ● Nested Expression builder ● person.dogs[0].name ● Move constrains up and down ● Insert constraints ● Support for more DRL elements ● RSS Subcription, change notifications, inbox ● Working Sets ● Object constraint definitions ● Rule Templates (based on Guided Editor) ● Oryx BPM editor integration ● Better rule documentation support
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
    11 Boot Camps  SanFrancisco 2009 (40+ attendees) ● Sponsored by Third Pillar ● Sun, FAMC, OSDE, Kaseya, Fedex, TU Group, Intermountain Healthcare, Gap, Sony Pictures, Lockheed Martin, Kaiser, HP, Wells Fargo, US Navy Research, FOLIOfn, Boeing .....  San Diego 2010 (80+ attendess) ● Sponsored by US Navy ● 5 day event, with 2 days focus on the healthcare industry ● OSDE, AT&T, SAIC, US Navy Research, Kaiser, Clinica, Intermountain Healthcare, GE Healthcare, VA, Boeing, Nationwide ....
  • 12.
    12 Boot Camps  RulesFest 11th October ● 3 day conferene + 1 day boot camp  USA and EMA in Febuary, watch blog for news ● http://blog.athico.com
  • 13.
    13 Community Collaboration  40%of Drools work now done in the community ● US Navy Healthcare ● OSDE (Argentina's largest healthcare organisation) ● Intalio
  • 14.
    14 Sample Industries andUsers  Investment ● Millennium Investment Group (MIG)  Logistics ● Fedex  Airline ● Sabre  Mortgage ● Franklin American  Healthcare ● OSDE
  • 15.
  • 16.
    16 It All StartedHere Birth of CDSS Dendral Baobab Mycin Guidon Neomycin Teiresias Puff Emycin WM Sacon Centaur Wheeze Gravida Clot Oncocin 1970s 1980s
  • 17.
    17 Because Not Everyone IsAs Smart As He Is
  • 18.
    18 Business Rules Engines OPS5 ART Clips Jess Drools2 JRules 1980s 2010s Drools 3 1990s 2000s Drools 4 Drools 5
  • 19.
    19 Drools History  Drools2 ● Rete “like” XML Scripting language  Drools 3 ● Based on Clips functionality ● Iterative improves to JRules syntax with Clips functionality  Drools 4 ● More declarative ● Basic functional programming feature with “from” ● Basic Rule Flow ● Basic BRMS  Drools 5 ● Improved functional programming with 'accumulate' ● More Advanced Rule Flow integration ● Complex Event Process (Fusion) ● Temporal Comparators, Sliding Time Windows ● Production ready BRMS
  • 20.
  • 21.
    21 Drools Modules Business Logicintegration System Drools Guvnor Drools Fusion Drools Flow (jBPM5) Drools Expert
  • 22.
  • 23.
  • 24.
    24 Rules and processes looselycoupledtightly coupled specificgeneric Decision Services Process Rules SCOPE COUPLING ?
  • 25.
  • 26.
  • 27.
  • 28.
    28 Hybrid Logic Engine Production Rule Systems PRD (forward chaining) ● Reactive ● when Alarm( status == “alert” ) then send( “warning” )  Logic Programming LP (backward chaining) ● Query ● descendant( “mary”, “jane”)  Functional Programming FP ● Map,Fold, Filter ● avg([12, 16, 4, 6]) ● Returns single value 9.5 ● round([10.3, 4.7, 7.8] ) ● Returns List [10, 5, 8]  Description Logic ● Person hasName String and livesAt Address
  • 29.
    29  Production RuleSystems PRD (forward chaining FC) ● Drools 5.0, OPSJ ( hyrbid BC), ART( hyrbid BC)  Logic Programming LP (backward chaining BC) ● target : Prolog (POSL Position Slotted Language) ● Drools Trunk has a prototype Prolog like query backward chaining capabilities. Stronger Polog like capabilities planned. ● Opportunistic BC planned.  Functional Programming FP ● Lisp, Haskell ● Drools 5.0 has some functional capabilities ● Drools 5.1, 5.2 will be looking to have strong functional capabilities Hybrid Logic Engine
  • 30.
    30  Description LogicDL ● KIF, OWL-DL ● Planned, See “The Future” Hybrid Logic Engine
  • 31.
    31 The Future  FullHybrid Engine ● http://community.jboss.org/wiki/DroolsLanguageEnhancements ●Nested Objects ●Casting Nested Objects ●Positional Constraints ●POSL - Positional-Slotted Language ●Method Calls ●Maps and Arrays (Collections) ●Collections and XPath like filtering ●Free form Expressions ●Managed Object Graphs (MOGS) ●Nested Patterns and Queries ●Queries and Unification ●Ontologies and Relations via ●Query Based Backward Chaining with POSL ●Triples with Hybrid POJO Graph Notation. ●Escapes for Dialects ●Accumulate Improvements to Support Haskell map/fold/filter and MVEL projection/fold ● Otherwise ● Branch (Labelled Else) ● Rule Execution Groups ● Rule Dependency Meta-Rule Language ●Parallel Meta-Rule Language ● Field Versioning ●Logical Closures/OnFalse ●Opportunistic Backward Chaining, Lazy Field/Object Values ●...
  • 32.
  • 33.
    33 jBPM File file =new File (“.....”); // file to XML process definition ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( IoUtils.FileToString( file ) ); ProcessInstance processInstance = new ProcessInstance(processDefinition); Jess Rete engine = new Rete(); FileReader file = new FileReader("myfile.clp"); Jesp parser = new Jesp(file, engine); parser.parse(false); Esper EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(); EPStatement countStmt = admin.createEPL( "...." ); countStmt.start(); Knowledge API
  • 34.
    34 Drools Flow KnowledegBuilder kbuilder= KnowledgeBuilderFactory.newKnowledgeBulider(); kbuilder.addResource( ResourceFactory.newClassPathResource( “myflow.bpmn2”, ResourceType.BPMN2 ); If ( kbuilder.hasErrors() ) { log.error( kbuilder.hasErrors().toString() ); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbase.getKnowledgePackages() ); Knowledge API
  • 35.
    35 Drools Expert KnowledegBuilder kbuilder= KnowledgeBuilderFactory.newKnowledgeBulider(); kbuilder.addResource( ResourceFactory.newClassPathResource( “myrules.drl”, ResourceType.DRL ); If ( kbuilder.hasErrors() ) { log.error( kbuilder.hasErrors().toString() ); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbase.getKnowledgePackages() ); Knowledge API
  • 36.
    36 Drools Integration DeploymentDescriptors <change-set> <add> <resource source='classpath:myapp/data/myflow.bpmn2' type='BPMN2' /> <resource source='http:myapp/data/myrules.drl' type='DRL' /> <resource source='classpath:data/IntegrationExampleTest.xls' type="DTABLE"> <decisiontable-conf input-type="XLS" worksheet-name="Tables_2" /> </resource> <add> </change-set> KnowledegBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBulider(); kbuilder.addResource( ResourceFactory.newFileResource( “changeset.xml”, ResourceType.ChangeSet ); Knowledge XML
  • 37.
    37 <drools:kbase id="kbase1"> <drools:resource type="DRL" source="classpath:.../testSpring.drl"/> </drools:kbase> <drools:ksessionid="ksession1" type="stateless" kbase="kbase1" /> <drools:ksession id="ksession2" type="stateful" kbase="kbase1"/> <camelContext id="camel"> <route> <from uri="cxfrs://bean://rsServer"/> <marshal ref="xstream"/> <to uri=”drools:ksession1” /> <unmarshal ref="xstream"/> </route> </camelContext> Declarative Services Spring XML and Camel
  • 39.
  • 40.
  • 41.
  • 42.
    42 D a ted a te d o u b le a m o u n t in t ty p e lo n g a c c o u n tN o C a s h flo w lo n g a c c o u n tN o d o u b le b a la n c e A c c o u n t D a te s ta r t D a te e n d A c c o u n tin g P e r io d Classes
  • 43.
    43 rule “increase balancefor AccountPeriod Credits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance += $amount; end select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end trigger : acc.balance += cf.amount Credit Cashflow Rule
  • 44.
    44 rule “increase balancefor AccountPeriod Credits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance += $amount; end rule “decrease balance for AccountPeriod Debits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == DEBIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance -= $amount; end Rules as a “view” date amount type 12-Jan-07 100 CREDIT 1 2-Feb-07 200 DEBIT 1 18-May-07 50 CREDIT 1 9-Mar-07 75 CREDIT 1 CashFlow accountNo CashFlow date amount type 12-Jan-07 100 CREDIT 9-Mar-07 75 CREDIT CashFlow date amount type 2-Feb-07 200 DEBIT AccountingPeriod start end 01-Jan-07 31-Mar-07 Account accountNo balance 1 0 Account accountNo balance 1 -25
  • 45.
  • 46.
    46 not Bus( color= “red” ) Conditional Elements exists Bus( color = “red” ) forall ( $bus : Bus( floors == 2 ) Bus( this == $bus, color == “red” ) ) forall ( $bus : Bus( color == “red” ) )
  • 47.
    47 Accumulate CE rule "accumulate" when acc(Bus( color == "red", $t : takings ); $min : min( $t ), $max : max( $t ); $min > 100 && $max < 200 ) then println( "range is “ + $min + “ “ + $max ); end
  • 48.
    48 Accumulate CE Patterns andCE's can be chained with 'from' rule "collect" when $zipCode : ZipCode() acc( Bus( color == "red", $t : takings ) from $hbn.getNamedQuery(“Find Buses”) .setParameters( [ “zipCode” : $zipCode ] ).list(); $sum : sum( $t ); $sum > 100 ) then print "sum is “ + $sum; end
  • 49.
  • 50.
    50 Live Queries query (String$region, int $min, int $max ) { $c : Cheese( region == $region, price > $min && price < $max ) exists( StockItem( type == $c ) } ViewChangedEventListener listener = new ViewChangedEventListener() { public void rowUpdated(Row row) { println( "updated" + row.get( "$c" ) ); } public void rowRemoved(Row row) { println( "removed" + row.get( "$c" ) ); } public void rowAdded(Row row) { println( "added" + row.get( "$c" ) ); } };
  • 51.
    51 Live Queries LiveQuery query= ksession.openLiveQuery( "cheeses", new Object[] { "devon", 10, 50 }, listener ); ... ... query.dispose()
  • 52.
  • 53.
    53 Timers rule “name” timer (int:1m30s 0) when $l : Light( status == “on” ) then modify( $l ) { status = “off” }; When the light is on, and has been on for 1m30s then turn it off
  • 54.
    54 Timers rule “name” timer (cron: 0 0/15 * * * * ) when Alarm( ) then sendEmail( ”Alert Alert Alert!!!” ) Field Name Mandatory? Allowed Values Allowed Special Characters Seconds YES 0-59 , - * / Minutes YES 0-59 , - * / Hours YES 0-23 , - * / Day of month YES 1-31 , - * ? / L W Month YES 1-12 or JAN-DEC , - * / Day of week YES 1-7 or SUN-SAT , - * ? / L # Year NO empty, 1970-2099 , - * / Send alert every quarter of an hour
  • 55.
    55 Calendars rule "weekdays arehigh priority" calendars "weekday" timer (int:0 1h) when Alarm() then send( "priority high - we have an alarm” ); end rule "weekend are low priority" calendars "weekend" timer (int:0 4h) when Alarm() then send( "priority low - we have an alarm” ); end Execute now and after 1 hour duration Execute now and after 4 hour duration
  • 56.
  • 57.
  • 58.
  • 59.
    59 Decision Table rule "Pricingbracket_10" when Driver(age >= 18, age <= 24, locationRiskProfile == "LOW", priorClaims == "1") policy: Policy(type == "COMPREHENSIVE") then policy.setBasePrice(450);
  • 60.
  • 61.
    61 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 Sequencing: ● A → ( B OR C ) → D  Event Abstraction: ● Ability to compose complex events from atomic events AND reason over them
  • 62.
    62 Drools Fusion: Features Support to Event semantics: ● Usually immutable, but not enforced ● Strong temporal relationships ● Managed lifecycle ● Point-in-time and Interval events  Time semantics ● Discrete  Temporal relationships ● All 13 operators defined by James Allen (+ negations)
  • 63.
    63 Drools Fusion: TemporalReasoning P o i n t - P o i n t P o i n t - I n t e r v a l I n t e r v a l - I n t e r v a l A b e f o r e B A m e e t s B A o v e r la p s B A f in is h e s B A in c lu d e s B A s t a r t s B A c o in c id e s B A B A B A B A B A B A B A B
  • 64.
    64 Drools Fusion: TemporalReasoning P o i n t - P o i n t P o i n t - I n t e r v a l I n t e r v a l - I n t e r v a l A a f t e r B A m e t B y B A o v e r la p e d B y B A f in is h e d B y B A d u r in g B A f in is h e s B A B A B A B A B A B A B
  • 65.
    65 $c : Custumer(type == “VIP ) $oe : BuyOrderEvent( customer == $c ) from entry-point “Home Broker Stream” not BuyAckEvent( relatedEvent == $oe.id, this after[1s, 10s] $oe ) from entry-point “Stock Trader Stream” Operators Existing Drools 'not' Conditional Elements can be used to detect non- occurrence of events BackAckEvent must occur between 1s and 10s 'after' BuyOrderEvent
  • 66.
    66 Aggregations Rule Engines donot deal with aggregations acc( $s : StockTicker( symbol == “RHAT” ) over window:time( 5s ); $avg : avg( $s.price ); $avg > 100 ) Over 5 seconds Aggregate ticker price for RHAT over last 5 seconds
  • 67.
    67 CEP Applied atFedEx Custom Critical  Time specific deliveries for critical freight  Exclusive use non-stop door-to-door services  Blended Surface and Air services to minimize cost and transit time  Extra care in handling and specially equipped vehicles ● Temperature Control, Secured Services, Hazardous Material, Constant Surveillance * Presented by Adam Mollemkopf at ORF 2009
  • 68.
    68 CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 69.
    69 CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 70.
    70 CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 71.
    71 CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 72.
    72 CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 73.
    73 CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 74.
    74  At least50% of Alerts can be reasoned automatically, promoting staff savings and improved Customer and Driver experiences.  Risk Avoidance via pro-active monitoring ● Reduction in insurance claims and shipment service failures  Minimum 30% efficiency gains in shipment monitoring , saving at least 15% of Operations staff cost. CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 75.
    75  Some numbers(from early 2010): ● 24 x 7 sessions, no downtime ● Average of 500k+ facts/events concurrently in memory ● Business hours: 1M+ facts/events concurrently ● Response time for reasoning cycles: ● Average: 150 ms ● Peak: 1.2 sec ● Several hundred rules CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 76.
  • 77.
    77 BPMN 2.0  OMGStandard that defines ● Graphical notation ● Process definition format (XSD/XMI) ● Execution Semantics  Extensible  Interoperability  http://www.omg.org/spec/BPMN/2.0
  • 78.
    78 Palette  Predefined setof generic node types ● start, end ● Gateway ● Script ● Sub-process ● Event ● ...
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
    83 Domain-Specific Processes  OtherExamples ● Email / notifications ● File management: archive, find, copy ● FTP, RSS, Jabber, Rest ● ESB ● Google Calendar, social websites  Library
  • 84.
  • 85.
  • 86.
    86 Events and Processes declareProcessStartedEvent @role( event ) end rule "Number of process instances above threshold" when acc( e: ProcessStartedEvent( processId == "com.sample.order.OrderProcess" ) over window:size(1h), $c : count(e), $c > 1000) then System.err.println( "WARNING: Nb of order processes in the last hour > 1000: " + nbProcesses ); end
  • 87.
  • 88.
    88 Questions?Questions? • Dave Bowman:All right, HAL; I'll go in through the emergency airlock. • HAL: Without your space helmet, Dave, you're going to find that rather difficult. • Dave Bowman: HAL, I won't argue with you anymore! Open the doors! • HAL: Dave, this conversation can serve no purpose anymore. Goodbye. Joshua: Greetings, Professor Falken. Stephen Falken: Hello, Joshua. Joshua: A strange game. The only winning move is not to play. How about a nice game of chess?