JBoss World 2011 - Drools

download JBoss World 2011 - Drools

If you can't read please download the document

Transcript of JBoss World 2011 - Drools

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 ProctorProject Lead

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Drools Vs BRMS

Drools
Grid

Drools
Planner

Drools
Semantics

Drools
Chance Business Logic integration System

Drools
Guvnor

Drools
Fusion

jBPM5(Drools
Flow)

Drools
Expert

RepositoryRules and MetadataJBoss Enterprise BRMS Platform

JBoss RulesRules Engine/ Execution

Rules Development & Management

CEPComplex Events

Jboss EWP

Drools Vs BRMS

derived Stand-alone Framework

Innovation

Fast and Frequent Releases

Tested on developer environments

Suitable for development and prototype

No Patches On to next big thing

Non SLA bound forum support

Fully Integrated Platform

Same Innovated Code + Stability

Stability Includes usability, performance and security issues identified during productization

Certified for Multi-OS, Multi-DB

Best for Development and Production

5 Yr lifecycle Includes patches, updates, backward compatibility

SLA based full support from dedicated support engineers

Open Source Assurance legal protection

JBoss Community & Enterprise Changes

Community / Enterprise Platform Delta

BRMS

5.0

5.1

5.1.0 Drools

Enterprise Platforms - Performance, Scalability, Security and Qualityimprove over time without
compromising long-term compatibility.

08/0912/1003/1105/11

44 bug fixes

8 perf. enhancements

6 security fixes

3 new features

41 bug fixes

4 security fixes

2 additional certs.

22 bug fixes

11 perf. enhancements

60 additional certs.

4 new features

5.1.05.1.1

Over 150+ defect fixes & 35+ OS/JVM/DB certifications (& counting) between Drools Community 5.1 & JBoss BRMS 5.1.x

150+ bug fixes

5 Security Fixes

5+ perf. enhancements

20+ additional certs.

Post GA Certs

15+ additional certs.

15+ bug fixes

Additional certs

Example release/support life cycle, highly simplified (not a roadmap) Multiple Community projects develop their own respective versions

Enterprise Platforms typically integrate many projects

Diagram = binary releases only (all source is public; source version of this diagram would be much more complex)

Community projects are always evolving

Major/minor releases that are annual/quarterly

Milestone releases that are approx. monthly

Community releases are always being evaluated for functional, performance, quality standards for inclusion in a Platform

Many Community releases are skipped over due to deficiencies

e.g. AS5.0 didn't meet perf/stability, so EAP waited for AS5.1; AS6.0 probably will not meet criteria

EAP alpha+beta+GA productization cycle follows Community AS Final release by 2-6 months

During EAP productization period, many Community members move on to work on next release (new features) of Community projects

For a given EAP release, support cycle lasts for 7 years

Full support (4 yrs) support + enhancements + patch releases

Transition (1 yr) support + patch releases

Maintenance (2 yrs) support + security patches only

Evolution of JBoss BRMS

Drools Framework05/08 04/09 12/10 ?

?

Lightweight Business Rules Engine

Business Rules Engine

Authoring and Management App

Repository

EAP Certified

DBs, JVMs

Business Rules Engine

Authoring and Management App

Choice of Repository

Integrated Container

CEP Tech Preview

EAP, EWS, EWP, JVMs, Dbs and more

Performance

Repository

JBoss Enterprise BRMS Platform 5.0

JBoss Rules

BRM

Repository

JBoss Enterprise BRMS Platform 5.1

JBoss Rules

BRM

CEP

Jboss EWPExample release/support life cycle, highly simplified (not a roadmap) Multiple Community projects develop their own respective versions

Enterprise Platforms typically integrate many projects

Diagram = binary releases only (all source is public; source version of this diagram would be much more complex)

Community projects are always evolving

Major/minor releases that are annual/quarterly

Milestone releases that are approx. monthly

Community releases are always being evaluated for functional, performance, quality standards for inclusion in a Platform

Many Community releases are skipped over due to deficiencies

e.g. AS5.0 didn't meet perf/stability, so EAP waited for AS5.1; AS6.0 probably will not meet criteria

EAP alpha+beta+GA productization cycle follows Community AS Final release by 2-6 months

During EAP productization period, many Community members move on to work on next release (new features) of Community projects

For a given EAP release, support cycle lasts for 7 years

Full support (4 yrs) support + enhancements + patch releases

Transition (1 yr) support + patch releases

Maintenance (2 yrs) support + security patches only

Back Up

JBoss Community vs. Enterprise (another view of differences, similar to previous slide but with a few more details)

Security Errata

Certifications

Out-of-the-box experience (e.g. configurations)

Management/monitoring tools

Software assurance / legal protection

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Sample Industries and Users

InvestmentMillennium Investment Group (MIG)

LogisticsFedex

AirlineSabre

MortgageFranklin American

HealthcareOSDE

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

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

It All Started Here
Birth of CDSS

DendralBaobabMycinGuidonNeomycinTeiresiasPuffEmycinWMSaconCentaurWheezeGravidaClot

Oncocin

1970s

1980s

Because Not Everyone
Is As Smart As He Is

Business Rules Engines

OPS5ARTClipsJessDrools 2JRules

1980s

2010s

Drools 3

1990s

2000s

Drools 4Drools 5

Drools History

Drools 2Rete like XML Scripting language

Drools 3 Based on Clips functionality

Iterative improves to JRules syntax with Clips functionality

Drools 4More declarative

Basic functional programming feature with from

Basic Rule Flow

Basic BRMS

Drools 5Improved functional programming with 'accumulate'

More Advanced Rule Flow integration

Complex Event ProcessTemporal Comparators

Sliding Time Windows

Production ready BRMS (Guvnor)

Drools History

Drools 5.1Differential Diff (true modify)

Drools 5.2 (CR1 this week)Freeform expressions between patterns

Multi-function accumulates

Prolog like derivation queries

Decision tables and rule templates (Guvnor)

Pure GWT (Guvnor)

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Classes

rule increase balance for AccountPeriod Credits when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && = ap.start and cf.date = ap.start && = ap.start && Everything is ok

Executing

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

Executing

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

rule "Status output when things are ok" when not Alarm() not Sprinkler( on === true ) then println( "Everything is ok" );end

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

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 ) )

Accumulate CE

rule "accumulate"when $sum : Number( intValue > 100 ) from accumulate( Bus( color == "red", $t : takings ) sum( $t ) )then print "sum is + $sum;end

Accumulate CE

Patterns and CE's can be chained with 'from'

rule "collect"when $zipCode : ZipCode() $sum : Number( intValue > 100 ) from accumulate( Bus( color == "red", $t : takings ) from $hbn.getNamedQuery(Find Buses) .setParameters( [ zipCode : $zipCode ] ) .list(), sum( $t ) )then print "sum is + $sum;end

Aggregations

Rule Engines do not deal with aggregations

$n : Number( intValue > 100 ) from accumulate( $s : StockTicker( symbol == RHAT ) over window:time( 5s ), average( $s.price ) )

Over 5 secondsAggregate ticker price for RHAT over last 5 secondsThe pattern 'Number' reasons 'from' the accumulate result

$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 eventsBackAckEvent must occur between 1s and 10s 'after' BuyOrderEvent

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Timers

rule name timer ( cron: 0 0/15 * * * * )when Alarm( )then sendEmail( Alert Alert Alert!!! )

Field Name Mandatory? Allowed Values Allowed Special CharactersSeconds YES 0-59 , - * /Minutes YES 0-59 , - * /Hours YES 0-23 , - * /Day of month YES 1-31 , - * ? / L WMonth 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

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 durationExecute now and after
4 hour duration

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

TMS and Inference

rule "Issue Child Bus Pass"when $p : Person( age < 16 )then insert(new ChildBusPass( $p ) );endrule "Issue Adult Bus Pass"when $p : Person( age >= 16 )then insert(new AdultBusPass( $p ) );end

Couples the logicWhat happens when the Child stops being 16?

TMS and Inference

BadMonolithic

Leaky

Brittle integrity - manual maintenance

TMS and Inference

A rule logically inserts an object

When the rule is no longer true, the object is retracted.

when $p : Person( age < 16 )then logicalInsert( new IsChild( $p ) )endwhen $p : Person( age >= 16 )then logicalInsert( new IsAdult( $p ) )end

de-couples the logicMaintains the truth by
automatically retracting

TMS and Inference

rule "Issue Child Bus Pass"when $p : Person( ) IsChild( person =$p )then logicalInsert(new ChildBusPass( $p ) );endrule "Issue Adult Bus Pass"when $p : Person( age >= 16 ) IsAdult( person =$p )then logicalInsert(new AdultBusPass( $p ) );end

The truth maintenance cascades

TMS and Inference

rule "Issue Child Bus Pass"when $p : Person( ) not( ChildBusPass( person == $p ) )then requestChildBusPass( $p );end

The truth maintenance cascades

TMS and Inference

GoodDe-couple knowledge responsibilities

Encapsulate knowledge

Provide semantic abstractions for those encapsulation

Integrity robustness truth maintenance

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Some decisions are simple

I want to treat myself

Some decisions are simple

Some decisions are complex

What insurance premiumshould I charge?

Some decisions are complex

Business considerationsApplicant's age

Applicant's experience

Sailing qualifications

Value of vessel

Type of cover

Some decisions are complex

Business considerationsApplicant's ageOnly insure people over 25 years of age

If less than 35 add 10% surcharge

If less than 45 add 5% surcharge

Some decisions are complex

Business considerationsApplicant's experienceIf sailing < 5 years then charge +10%

Sailing qualificationsNone charge +100%

Etc...

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Enter the decision table

Extract of decision table

Decision Table

Decision Table

rule "Pricing bracket_10"

when Driver(age >= 18, age = "18" , age < "45" , lengthOfService < "15" )

then

$person.setHolidayEntitlement( 22 );

end

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Types

Types

Layout Horizontal

Vertical

Limited entry

Extended entry

Categorisation Expanded form, contracted form

Multi-hit, all hits

Multi-hit, first hit

Single hit

Layouts

Horizontal

Layouts

Vertical

Layouts

Limited entry

Layouts

Extended entry

Categorisation

Expanded form

Single column for every condition combination

The number of columns should equal the product of the number of states for every condition.e.g. 3 conditions each with 2 states gives:

2 * 2 * 2 = 8 combinationse.g. 2 conditions each with 3 states and 1 condition with 4 states gives:

3 * 3 * 4 = 36 combinations

Categorisation

Expanded form (continued)

Condition states should be digitised e.g. age: 60 not a free-form integer field

Condition states should be continuouse.g. GOOD: age=18; BAD: age=30

Not essential for expansion but ensures completeness

This guarantee of completeness of condition combinations is one of the main advantages of decision tables.

Categorisation

Expanded form (continued)

Categorisation

Contracted form

Contraction is the first optimisation.

Reduces the number of condition columns.

If the same actions exist for rules covering all condition states for a given condition they can be combined and the condition state becomes irrelevant.

Categorisation

Contracted form stage 1Rules 2 and 3 are impossible conditions

Categorisation

Contracted form stage 2Merge adjacent column groups with identical action parts

Categorisation

Multi-hit, all hits

To get complete result all rules matching need to have their actions executed.

Condition columns are not mutually exclusive

If the Condition columns are not exclusive, some combination of conditions are present in more than one column, which may lead to ambiguity or inconsistency.

Categorisation

Multi-hit, all hits

Given a 35 year old with 15 years service1. Rule 1 matches, giving 22 days2. Rule 5 matches, giving an additional 3 days3. A total of 25 days is assigned

Categorisation

Multi-hit, first hit

To get complete result the first rule (from left-to-right) matching needs to have its action executed.

Condition columns are not mutually exclusive.

If the Condition columns are not exclusive, some combination of conditions are present in more than one column, which may lead to ambiguity or inconsistency.

Categorisation

Multi-hit, first hit

Given a 35 year old with 15 years service1. Rule 4 matches, giving 25 days2. Rule 6 would match but Rule 4 was the first hit

Categorisation

Single hit

Each possible combination of conditions matches exactly one, and only one, rule.

Condition columns are mutually exclusive

As the Condition columns are exclusive; combinations of conditions cannot be present in more than one column which eliminates ambiguity and inconsistency.

Classic form if Single-hit is "expanded decision table"; but this can be optimised or contracted.

Categorisation

Single hit

Given a 35 year old with 15 years service1. Rule 3 matches, giving 25 days2. No other rules match

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Decision Tables in Guvnor

What do we currently provide?

Vertical layout

Generalised categorisationMulti-hit, all hit; Multi-hit first hit; Single hit

Extended entry

Digitised condition states (enumerated fields)

New decision table editor

Foundation for future work

Condition and rule negation

Cell merging

Cell grouping

Decision Tables in Guvnor

What do we currently provide?

Cell merging

Decision Tables in Guvnor

What do we currently provide?

Cell grouping

Decision Tables in Guvnor

What do we currently provide?

Video demonstration

Demonstration available online at http://vimeo.com/21438537

Agenda

Product Overview

Community

History

Drools ExpertQuick Example Stateless

Quick Example Stateful

Conditional elements

Timers and Calendars

Truth maintenance and Inference

Decision TablesDecisions

Enter the Decision table

Types

Decision tables in guvnor

Roadmap

Roadmap

What does the future hold?

Provision of other layoutsHorizontal

Limited entry

Automated optimisation

Improved support for digitised condition states

Integration of V&V providing visual feedback

Pluggable editors for Model Fact Types

Usability enhancements

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?

Backward Chaining

query isContainedIn( String x, String y ) Location(x, y;) or ( Location(z, y;) and ?isContainedIn(x, z;) )end\n"

rule reactiveLook when Here( place : place) ?isContainedIn(place, "keys";)\then\n" + System.out.println( "We have found your keys");end

Click to edit the title text format

Click to edit the outline text format

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level

Click to edit the title text format

Click to edit the text format

Click to edit the title text format

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level

This is the title
Second line of the title

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level

Click to edit the title text format

Click to edit the text format

CashFlow

dateamounttypeaccountNo

12-Jan-07100CREDIT1

2-Feb-07200DEBIT1

18-May-0750CREDIT1

9-Mar-0775CREDIT1

???Page ??? (???)04/05/2011, 12:38:29Page / CashFlow

dateamounttype

12-Jan-07100CREDIT

9-Mar-0775CREDIT

???Page ??? (???)04/05/2011, 12:38:29Page / CashFlow

dateamounttype

2-Feb-07200DEBIT

???Page ??? (???)04/05/2011, 12:38:29Page / AccountingPeriod

startend

01-Jan-0731-Mar-07

???Page ??? (???)04/05/2011, 12:38:30Page / Account

accountNobalance

10

???Page ??? (???)04/05/2011, 12:38:30Page / Account

accountNobalance

1-25

???Page ??? (???)04/05/2011, 12:38:30Page /