• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Drools 6.0 (CamelOne 2013)
 

Drools 6.0 (CamelOne 2013)

on

  • 826 views

Presentation that gives a quick intro into Drools, and an overview of some things coming in Drools 6.0. This presentation was given at CamelOne 2013

Presentation that gives a quick intro into Drools, and an overview of some things coming in Drools 6.0. This presentation was given at CamelOne 2013

Statistics

Views

Total Views
826
Views on SlideShare
826
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Drools 6.0 (CamelOne 2013) Drools 6.0 (CamelOne 2013) Presentation Transcript

    • Saturday, 29 June 13
    • Who am I? • Drools co-founder • JBoss (2005) • Red Hat (2006) • Polymita Acquisition 2012 • Red Hat Platform Architect Saturday, 29 June 13
    • Saturday, 29 June 13
    • Saturday, 29 June 13
    • Codehaus Parties - Amsterdam 2003 Saturday, 29 June 13
    • Saturday, 29 June 13
    • Saturday, 29 June 13
    • Saturday, 29 June 13
    • Saturday, 29 June 13
    • What’s a Rule Saturday, 29 June 13
    • This is a Rule Saturday, 29 June 13
    • This is another Rule function checkemail(email){ var filter= /^([w-]+(?:.[w-]+)*)@((?:[w-]+ .)*w[w-]{0,66}).([a-z]{2,6}(?:. [a-z]{2})?)$/i if ( filter.test(email) ) { return true } else{ return false } } Saturday, 29 June 13
    • This is a Rule Enginevar validator = new FormValidator('example_form', [{ name: 'req', display: 'required', rules: 'required' }, { name: 'alphanumeric', rules: 'alpha_numeric' }, { name: 'password', rules: 'required' }, { name: 'password_confirm', display: 'password confirmation', rules: 'required|matches[password]' }, Saturday, 29 June 13
    • These are Rules too Saturday, 29 June 13
    • What is a Rule rule <rule_name> <attribute><value> when <conditions> then <actions> end Saturday, 29 June 13
    • Pattern Matching Person(age >= 18) field name restriction constraintobject type pattern Saturday, 29 June 13
    • Pattern Matching ? case class Grade( letter : String, passed : Boolean ) def check( grade : Grade ) = { grade match { case Grade(letter,true) => printf( "You have passed with grade: %s", letter ) case Grade(letter,false) => printf( "You have failed with grade: %s", letter ) } } Saturday, 29 June 13
    • Hybrid Reasoning Saturday, 29 June 13
    • 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 rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end 19 acc.balance += cf.amount CashFlow Rule Saturday, 29 June 13
    • 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 rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end 20 acc.balance += cf.amount CashFlow Rule Saturday, 29 June 13
    • 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 rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end 21 acc.balance += cf.amount CashFlow Rule Saturday, 29 June 13
    • 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 rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end 22 acc.balance += cf.amount CashFlow Rule Saturday, 29 June 13
    • 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 rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end 23 acc.balance += cf.amount CashFlow Rule Saturday, 29 June 13
    • 24 Classes AccountAccount long accountNo int balance CashFlowCashFlow Date date int amount AccountPeriodAccountPeriod Date start Date end CashFlow Example Saturday, 29 June 13
    • 25 rule "Increase balance for AccountPeriod Credits" when ap : AccountPeriod( ) acc : Account( ) cf : CashFlow( type == CashFlowType.CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance = acc.balance + cf.amount; end rule "Decrease balance for AccountPeriod Debits" when ap : AccountPeriod( ) acc : Account( ) cf : CashFlow( type == CashFlowType.DEBIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance = acc.balance - cf.amount; end CashFlowCashFlowCashFlowCashFlow date amount type accountNo 12-Jan-12 100 CREDIT 1 2-Feb-12 200 DEBIT 1 18-May-12 50 CREDIT 1 9-May-12 75 CREDIT 1 AccountingPeriodAccountingPeriod start end 01-JAN-2012 31-MAR-2012 AccountAccount accountNo balance 1 0 CashFlowCashFlowCashFlowCashFlow date amount type accountNo 12-Jan-12 100 CREDIT 1 9-May-12 75 CREDIT 1 CashFlowCashFlowCashFlowCashFlow date amount type accountNo 2-Feb-12 200 DEBIT 1 AccountAccount accountNo balance 1 -25 CashFlow Example Saturday, 29 June 13
    • 26 rule "Print blance for AccountPeriod" salience -50 when ap : AccountPeriod() acc : Account( ) then System.out.println( "Account Number " + acc.accountNo + " balance " + acc.balance ); end AgendaAgendaAgenda 1 increase balance arbitrary2 decrease balance arbitrary 3 increase balance arbitrary 4 print balance CashFlow Example Saturday, 29 June 13
    • Timers Saturday, 29 June 13
    • Timers Saturday, 29 June 13
    • CEP Saturday, 29 June 13
    • BRMS 5.x UI Saturday, 29 June 13
    • Saturday, 29 June 13
    • Guided Editor Saturday, 29 June 13
    • Decision Table Saturday, 29 June 13
    • •Merging Decision Table Saturday, 29 June 13
    • •Merging •Grouping Decision Table Saturday, 29 June 13
    • Decision Table Wizards Saturday, 29 June 13
    • Rule Templates Saturday, 29 June 13
    • Rule Templates Saturday, 29 June 13
    • Saturday, 29 June 13
    • BRMS 6.0 Simplified Utilization Saturday, 29 June 13
    • BRMS 5.0 Programmatic API KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.batch().add( newClassPathResource( "Model.drl", getClass() ), DRL ) .add( newClassPathResource( "Queries.drl", getClass() ), DRL ) .add( newClassPathResource( "General.drl", getClass() ), DRL ) .add( newClassPathResource( "Response.drl", getClass() ), DRL ) .add( newClassPathResource( "Events.drl", getClass() ), DRL ) .add( newClassPathResource( "UiView.drl", getClass() ), DRL ) .add( newClassPathResource( "Commands.drl", getClass() ), DRL ).build(); if ( kbuilder.hasErrors() ) { System.out.println( kbuilder.getErrors().toString() ); System.exit( 1 ); } KieBaseConfiguration kbaseConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); kbaseConf.setOption( EqualityBehaviorOption.EQUALITY ); KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( kbaseConf ); kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); Counter c = new Counter(); ksession = kbase.newStatefulKnowledgeSession(); Saturday, 29 June 13
    • KieModules <kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/kie/6.0.0/kmodule"> </kmodule> KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.getKieClasspathContainer(); KieSession kSession = kContainer.newKieSession(); kSession.setGlobal("out", out); kSession.insert(new Message("Dave", "Hello, HAL. Do you read me, HAL?")); kSession.fireAllRules(); Saturday, 29 June 13
    • KieModules• Package location can over-ride kbase name defaults <kbase name="WumpusMainKB" packages="org.drools.games.wumpus.server, org.drools.games.wumpus.server.view"> <ksession name="WumpusMainKS" /> </kbase> <kbase name="WumpusClientKB" packages="org.drools.games.wumpus.client"> <ksession name="WumpusClientKS"/> </kbase> KieContainer kc = KieServices.Factory.get().getKieClasspathContainer(); final KieSession serverKsession = kc.newKieSession( "WumpusMainKS"); final KieSession clientKsession = kc.newKieSession("WumpusClientKS"); Saturday, 29 June 13
    • kmodule.xml Editor Saturday, 29 June 13
    • Dynamic KieModules • kie-ci use embedded maven for remote discovery <dependency> <groupId>org.kie</groupId> <artifactId>kie-ci</artifactId> </dependency> KieServices ks = KieServices.Factory.get(); // Install example1 in the local maven repo before to do this KieContainer kContainer = ks.newKieContainer( ks.newReleaseId("org.drools", "named-kiesession", "6.0.0-SNAPSHOT")); KieSession kSession = kContainer.newKieSession("ksession1"); kSession.setGlobal("out", out); Object msg1 = createMessage(kContainer, "Dave", "Hello, HAL. Do you read me, HAL?"); kSession.insert(msg1); kSession.fireAllRules(); Saturday, 29 June 13
    • BRMS 6.0 CDI Saturday, 29 June 13
    • CDI Context and Dependency • CDI injects named entities from the kmodule.xml • Injectable types • KieServices • KieContainer • KieBase • KieSession • StatelessKieSession Saturday, 29 June 13
    • KBase @Inject @KBase(value="jar1.KBase1", name="kb2") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0") private KieBase jar1KBase1kb2; @Inject @KBase(value="jar1.KBase1", name="kb2") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0") private KieBase jar1KBase1kb22; @Inject private KieBase defaultClassPathKBase; @Inject @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0") private KieBase defaultDynamicKBase; @Inject @KBase("jar1.KBase1") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0") private KieBase jar1KBase1v10; @Inject @KBase("jar1.KBase1") @KReleaseId(groupId = "jar1", artifactId = "art1", version = "1.1") private KieBase jar1KBase1v11; @Inject @KBase(value="jar1.KBase1", name="kb1") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0") private KieBase jar1KBase1kb1; Saturday, 29 June 13
    • KSession @Inject @KSession("jar1.KSession2") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0" ) private KieSession kbase1ksession2v10; @Inject @KSession("jar1.KSession2") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.1" ) private KieSession kbase1ksession2v11; @Inject @KSession(value="jar1.KSession2", name="ks1") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0" ) private KieSession kbase1ksession2ks1; @Inject @KSession(value="jar1.KSession2", name="ks2") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0" ) private KieSession kbase1ksession2ks2 ; @Inject @KSession(value="jar1.KSession2", name="ks2") @KReleaseId( groupId = "jar1", artifactId = "art1", version = "1.0" ) private KieSession kbase1ksession2ks22; Saturday, 29 June 13
    • BRMS 6.0 Spring and Camel Saturday, 29 June 13
    • Spring and Camel Saturday, 29 June 13
    • Spring and Camel Saturday, 29 June 13
    • Spring and Camel Saturday, 29 June 13
    • Spring and Camel Saturday, 29 June 13
    • BRMS 6.0 Score Cards Saturday, 29 June 13
    • Score Cards• a) Setup Parameters • b) Characteristic Section Saturday, 29 June 13
    • Score Cards• UI Generates PMML • DRL Generated from PMML • DRL results in • Calculated Score • Ranked Reason Codes • Can import PMML 4.1 • but not exposed yet • Calculated Scores • Currently Summations • Weight coming • Not in PMML standard • Saturday, 29 June 13
    • 6.0 JTMS Saturday, 29 June 13
    • Justification-based Truth • Drools 5.x • Simple logical insertion TMS, like Clips, Jess and others. • Drools 6.0 • Contradiction handling with JTMS • Clean separation of exception logic • TMS now has pluggable Belief System • Simple TMS support • JTMS now possible. • Defeasible Logic soon • See drools-compiler • JTMSTest for lots of example tests Saturday, 29 June 13
    • 60 JTMS Couples the logic What happens when the Child stops being 16? rule "Issue Child Bus Pass" when $p : Person( age < 16 ) then insert(new ChildBusPass( $p ) ); end rule "Issue Adult Bus Pass" when $p : Person( age >= 16 ) then insert(new AdultBusPass( $p ) ); end Saturday, 29 June 13
    • JTMS • Bad • Monolithic • Leaky • Brittle integrity - manual maintenance Saturday, 29 June 13
    • 62 JTMS de-couples the logic Maintains the truth by automatically retracting •A rule “logically” inserts an object •When the rule is no longer true, the object is retracted. rule "IsChild" when $p : Person( age < 16 ) then logicalInsert( new IsChild( $p ) ) end rule "IsAdult" when $p : Person( age >= 16 ) then logicalInsert( new IsAdult( $p ) ) end Saturday, 29 June 13
    • 63 JTMS The truth maintenance cascades rule "Issue Child Bus Pass" when $p : Person( ) IsChild( person =$p ) then logicalInsert(new ChildBusPass( $p ) ); end rule "Issue Adult Bus Pass" when $p : Person() IsAdult( person =$p ) then logicalInsert(new AdultBusPass( $p ) ); end Saturday, 29 June 13
    • 64 JTMS rule "Issue Child Bus Pass" when $p : Person( ) not( ChildBusPass( person == $p ) ) then requestChildBusPass( $p ); end The truth maintenance cascades Saturday, 29 June 13
    • 65 JTMS • Good • De-couple knowledge responsibilities • Encapsulate knowledge • Provide semantic abstractions for those encapsulation • Integrity robustness – truth maintenance Saturday, 29 June 13
    • JTMS IsChild ChildBusPas Rule : isChildRule Rule : IssueBusPas + + Saturday, 29 June 13
    • JTMS rule "Do not issue to banned people" when $p : Person( ) Banned( person =$p ) then logicalInsert(new ChildBusPass( $p ) , “neg” ); end Saturday, 29 June 13
    • JTMS IsChild ChildBusPas Rule : isChildRule Rule : IssueBusPas + + Rule : Do Not Issue to Banned People - Saturday, 29 June 13
    • BRMS 6.0 R.I.P Rete Saturday, 29 June 13
    • R.I.P RETE inspirations: • Leaps, Collection Oriented Match, L/R Unlinking New Innovations • Full Rule, and Rule Segment Unlinking • Lazy Evaluation, with Rule scoping • Set propagations Previous Innovations • Modify In Place • Property Reactive • Tree Based Graphs • Subnetwork support Saturday, 29 June 13
    • BRMS 6.0 UI - OpenShift Ready Saturday, 29 June 13
    • 5.x Critique Saturday, 29 June 13
    • 5.x Critique UI • GWT • but not easily extended • fixed layouts • no perspectives Saturday, 29 June 13
    • 5.x Critique UI • GWT • but not easily extended • fixed layouts • no perspectives JCR • Performance Issues • Everything stored as blob • No tagging, branching etc. • Webdav • Limited team providers Saturday, 29 June 13
    • 5.x Critique UI • GWT • but not easily extended • fixed layouts • no perspectives JCR • Performance Issues • Everything stored as blob • No tagging, branching etc. • Webdav • Limited team providers Deployment • Binary blobs, on url Saturday, 29 June 13
    • UF UberFire Saturday, 29 June 13
    • Requirements • GWT + Errai • Modular design • Plugins • Common Life cycles • Compile time composition of plugins, via maven • Flexible layouts • Perspectives • GIT Backend • High Availability • Maven integration for “projects” Saturday, 29 June 13
    • UberFire Architecture Overview Saturday, 29 June 13
    • Saturday, 29 June 13
    • •Modular •Extensible •Dynamic and Flexible layouts •Perspectives Saturday, 29 June 13
    • Simple POM Editor Saturday, 29 June 13
    • Build and Deploy Saturday, 29 June 13
    • Local Maven Repository and Manager Saturday, 29 June 13
    • Create or Clone Git Repos Saturday, 29 June 13
    • KIE - Knowledge Is Everything Saturday, 29 June 13
    • KIE - Knowledge Is Everything Saturday, 29 June 13
    • KIE - Knowledge Is Everything Saturday, 29 June 13
    • Community Beta3 Demo Saturday, 29 June 13
    • Saturday, 29 June 13
    • UI Improvments Saturday, 29 June 13
    • UberFire new Navigation System Saturday, 29 June 13
    • UberFire new Navigation System Saturday, 29 June 13
    • UberFire new Navigation System Saturday, 29 June 13
    • UberFire new Navigation System Saturday, 29 June 13
    • BPM Integration Saturday, 29 June 13
    • BPMS 6.0 Saturday, 29 June 13
    • Work - Task Lists Saturday, 29 June 13
    • Work - Task Lists Saturday, 29 June 13
    • Work - Task Lists Saturday, 29 June 13
    • Work - Task Lists Saturday, 29 June 13
    • Work - Task Lists Saturday, 29 June 13
    • Work - Task Lists Saturday, 29 June 13
    • BPMN Designer (JS) Saturday, 29 June 13
    • Serious Bits :) http://www.youtube.com/watch?v=Omj4PR3v-nI http://www.youtube.com/watch?v=4CvjKqUOEzM Saturday, 29 June 13