SlideShare a Scribd company logo
1 of 107
Download to read offline
Ray Ploski
                            Director - Developer Experience




          Drools and
          the BRMS
The Business Logic Integration Platform
Agenda
ā€¢ The Concepts
ā€¢ A Simple Example and Demo
ā€¢ Projects Overview
ā€¢ Best practices integrating Drools into
  your development process

ā€¢ Learning more, getting involved and
  getting support
What is Drools?



         Planner
What is JBoss BRMS?
JBoss Enterprise BRMS                               BRMS
ā€¢ Single, integrated, certified
  distributions
ā€¢ Extensive Q/A Process
ā€¢ Industry-leading Support
ā€¢ Documentation
ā€¢ Secure, Production-level
  Configurations                               JBoss Runtime
ā€¢ Multi-year Errata Policy

A common and complete platform to model and govern the business logic of the
                               enterprise
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:


                                    1                    2                     3                         4                         5
Delivery Phase




                                  Drools Projects     Product                                      Platform Testing,         Platform Release
                                                                     Platform Component
                                                    Requirements                                    Certification &        (General Availability)
                                                                   Engineering & Integration
                                                      Definition                                    Documentation




                                                                        Platform                       Quality
                                                                                                                                JBoss
                                                                       Candidate                                                BRMS
                                                                                                                              Enterprise
Productization Team




                                                                                                      Assurance
                                                                       Release(s)                                               BRMS

                                                                                               JBoss QA, Documentation      JBoss Release
                                                                           JBoss
                                                      Product                                   Team, Certified Partners     Engineering
                                                                        Productization
                                                    Management            Engineers

                                 JBoss.org
                                 Engineers




                                                                           6
The
Concepts
The Typical SDLC
   View Layer     Service Layer

        Business Layer

       Persistence Layer
The Typical SDLC
   View Layer     Service Layer

        Business Layer

       Persistence Layer
The Typical SDLC
   View Layer     Service Layer

        Business Layer

       Persistence Layer
The Typical SDLC
   View Layer     Service Layer

        Business Layer

       Persistence Layer
The Typical SDLC
   View Layer     Service Layer

        Business Layer

       Persistence Layer
The Typical SDLC
   View Layer     Service Layer

        Business Layer

       Persistence Layer
The Typical SDLC
   View Layer     Service Layer

      Business Layer

       Persistence Layer
Extract the Logic
Extract the Logic
ā€¢ Separate integration codebase
 from business logic and into a
 rules engine
Extract the Logic
ā€¢ Separate integration codebase
 from business logic and into a
 rules engine
ā€¢ Goal: Remove the requirements
 churn and complexity
Extract the Logic
ā€¢ Separate integration codebase
 from business logic and into a
 rules engine
ā€¢ Goal: Remove the requirements
 churn and complexity
ā€¢ Goal: Empower your Domain
 Experts to directly author rules
Business Logic
Business Logic

ā€¢ Rules
Business Logic

ā€¢ Rules
ā€¢ Process
Business Logic

ā€¢ Rules
ā€¢ Process
ā€¢ Response to Events
Business Logic

ā€¢ Rules
ā€¢ Process
ā€¢ Response to Events
ā€¢ Planning Problems
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
What is a Rules Engine?
What is a Rules Engine?
ā€¢ Ambiguous Term
What is a Rules Engine?
ā€¢ Ambiguous Term
ā€¢ Inference Engine Concepts Clarify
 ā€¢ Scales to a large number of rules and
   facts

 ā€¢ Matches facts against rules to infer
   conclusions

 ā€¢ Conclusions result in actions
                                   rule ā€œXYZā€
                                   when
                                        <conditions>


 ā€¢ Simple two-part structure:
                                   then
                                        <actions>
Facts
ā€¢ POJOs (Plain Old Java Objects)
 ā€¢ Rules engine uses to evaluate conditions
 ā€¢ Rules engine can execute POJO methods
 ā€¢ Can be loaded from a database via
    Hibernate, JPA, etc...

 ā€¢ Rules engine can modify a factā€™s state
ā€¢ Dynamic Facts
 ā€¢ Can be modeled in the Web UI
Facts
ā€¢ POJOs (Plain Old Java Objects)
 ā€¢ Rules engine uses to evaluate conditions
 ā€¢ Rules engine can execute POJO methods
 ā€¢ Can be loaded from a database via
    Hibernate, JPA, etc...

 ā€¢ Rules engine can modify a factā€™s state
ā€¢ Dynamic Facts
 ā€¢ Can be modeled in the Web UI
Fact Model Example
public class Room {                     Model is multiple
    private String name
    // getter and setter methods here    facts and their
}                                         relationships
public class Sprinkler {
    private Room room;
    private boolean on;
    // getter and setter methods here
}
public class Fire {
    private Room room;
    // getter and setter methods here
}
public class Alarm {
}
Fact Model Example
public class Room {                     Model is multiple
    private String name
    // getter and setter methods here    facts and their
}                                         relationships
public class Sprinkler {
    private Room room;
    private boolean on;                 ā€¢   Must have setters/
    // getter and setter methods here       getters
}
public class Fire {                     ā€¢   Must have a public
                                            no-arg constructor
    private Room room;
    // getter and setter methods here   ā€¢   No mandatory
}                                           inheritance/
public class Alarm {                        interface
}
Rules
Rules
ā€¢ Form the ā€œIF/Thenā€ action defined as ā€œWhen/Thenā€
Rules
ā€¢ Form the ā€œIF/Thenā€ action defined as ā€œWhen/Thenā€
ā€¢ Must have a name that is unique for a rule
  package
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
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
ā€¢ 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
ā€¢ 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
     ā€¢ 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!
Rules in DRL
package 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
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
Rule Control
ā—   no-loop
    āœ“   short circuit rule recursion
ā—   salience
    āœ“   numeric value that represents rule importance
ā—   agenda-group
    āœ“   ļ¬re rules in group only when in focus
ā—   auto-focus
    āœ“   trigger focus change to the rule's agenda-group
ā—   activation-group
    āœ“   ļ¬rst matching rule ļ¬res
    āœ“   all other rules in group are ignored lock-on-active
ā—   date-effective, date-expires
    āœ“   deļ¬ne rules that are only active at certain points in time
ā—   template
    āœ“   deļ¬ne templates that may be reused in multiple rules
Avenues for Authoring Rules

                         - Dynamic Facts
                         - Decision Tables
                         - Guided Rules
                         - English/Industry Speciļ¬c Rules
                         - Guided Tests
                         - Scenario Tests
                         - Asset Search
                         - Browse by Category
                         - Browse by Status

    Web Broswer




                         - Spreadsheet Decision Tables




    Spread sheet




                         - Technical Rules (.drl)
                         - Enumerations
                         - Domain Speciļ¬c Language
                         - Templates
                         - Rule Flow
                         - Step-debugging
                         - Agenda Views and Inspection
                         - Working Memory Inspection
                         - Rule Engine Audit Trails
                         - Technical Tests
                         - Technical Test Suites
JBoss Developer Studio
BRMS ā€“ Rich UI for Business Rules




               20
Fact Model Editor




        21
Guided Rule Editor (Web)




           22
Web Decision Table Editor




            23
Decision Tables




       24
Discussions & Inbox
DroolsDoc
Single Asset Verification
Multiple View / Edits in a Single Tab
From, Collect & Accumulate Support




From CE




           From Collect CE




                               From Accumulate CE
Rule Template Support
Working Sets
Fact Constraints within WorkingSets
Runtime
Runtime: Building
private static 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);
	 	 	 }
	 	 	 throw new IllegalArgumentException("Could not parse knowledge.");
	 	 }
	
   	 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	 	 kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	 	 return kbase;
	 }
Runtime: Building
private static 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);
	 	 	 }
	 	 	 throw new IllegalArgumentException("Could not parse knowledge.");
	 	 }
	
   	 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	 	 kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	 	 return kbase;
	 }
Runtime: Building
private static 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);
	 	 	 }
	 	 	 throw new IllegalArgumentException("Could not parse knowledge.");
	 	 }
	
   	 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	 	 kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	 	 return kbase;
	 }
Runtime: Building
private static 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);
	 	 	 }
	 	 	 throw new IllegalArgumentException("Could not parse knowledge.");
	 	 }
	
   	 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	 	 kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	 	 return kbase;
	 }
Runtime: Building
private static 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);
	 	 	 }
	 	 	 throw new IllegalArgumentException("Could not parse knowledge.");
	 	 }
	
   	 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	 	 kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	 	 return kbase;
	 }
Camel & Spring Configuration
<beansĀ xmlns="http://www.springframework.org/schema/beans"
Ā Ā Ā Ā Ā Ā Ā xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Ā Ā Ā Ā Ā Ā Ā xmlns:drools="http://drools.org/schema/drools-spring"Ā Ā Ā Ā Ā Ā Ā 
Ā Ā Ā Ā Ā Ā http://drools.org/schema/drools-springĀ http://verylongurl/drools-spring-1.0.0.xsd>

Ā Ā <drools:resourceĀ id="resource1"Ā type="DRL"Ā source="classpath:orgth:org/drools/container/spring/testSpring.drl"/>

Ā Ā <drools:kbaseĀ id="kbase1">
Ā Ā Ā Ā <drools:resources>
Ā Ā Ā Ā Ā Ā <drools:resourceĀ type="DRL"Ā source="classpath:org/drools/container/spring/testSpring.drl"/>
Ā Ā Ā Ā Ā Ā <drools:resourceĀ ref="resource1"/>
Ā Ā Ā Ā Ā Ā <drools:resourceĀ source="classpath:org/drools/container/spring/IntegrationExampleTest.xls"Ā type="DTABLE">
Ā Ā Ā Ā Ā Ā Ā Ā <drools:decisiontable-confĀ input-type="XLS"Ā worksheet-name="Tables_2"Ā />
Ā Ā Ā Ā Ā Ā </drools:resource>
Ā Ā Ā Ā </drools:resources>

Ā Ā Ā Ā <drools:configuration>
Ā Ā Ā Ā Ā Ā <drools:mbeansĀ enabled="true"Ā />
Ā Ā Ā Ā Ā Ā <drools:event-processing-modeĀ mode="STREAM"Ā />
Ā Ā Ā Ā </drools:configuration>
Ā Ā </drools:kbase>
</beans>




                   THE BRE now has extensive Spring support, the XSD
                      can be found in the the drools-spring jar. The
                   namespace is "http://drools.org/schema/drools-spring"
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();
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();
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();
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();
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();
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();
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
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();
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 ofļ¬ce
Runtime - Execution
	   ksession.retract( kitchenFireHandle );
	   ksession.retract( officeFireHandle );
	   ksession.fireAllRules();
Runtime - Execution
	    ksession.retract( kitchenFireHandle );
	    ksession.retract( officeFireHandle );
	    ksession.fireAllRules();
	    	   	




    > Turn off the sprinkler for room ofļ¬ce
    > Turn off the sprinkler for room kitchen
    > Cancel the alarm
    > Everything is ok
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
Runtime Visibility - JMX
ā€¢ Drools 5.3 brings support to the JMX standard and
  enables knowledge base and knowledge session
  monitoring and inspection using any JMX console.




                     KnowledgeBase Stats
Runtime Visibility - JMX

            KnowledgeSession Stats
Deployment
  - Packaging
  - Snapshots                                    - Asset Search
  - Status Deļ¬nition                             - Browse by Category
  - User Administration                          - Browse by Status
  - Categorization



Analysis

  - Step-debugging
  - Agenda Views and Inspection                  - Rule Authoring Analysis
  - Working Memory Inspection                    - Guided Test Audit Trails
  - Rule Engine Audit Trails




Tests
  - Technical Tests                              - Guided Tests
  - Technical Test Suites                        - Scenario Tests




Rules

  - Technical Rules (.drl)                       - Decision Tables
  - Enumerations
  - Domain Speciļ¬c Language                      - Decision Tables
  - Templates                                    - Guided Rules
  - Rule Flow                                    - English/Industry Speciļ¬c Rules



Facts

               Java Jars                                   Dynamic Facts



           Developer-centric                           Business Analyst


    Web-only Feature                               Modiļ¬able via Developer IDE

    Modiļ¬able via Web Browser or Developer IDE     Modiļ¬able via Excel/OpenOfļ¬ce
Deployment
  - Packaging
  - Snapshots                                    - Asset Search
  - Status Deļ¬nition                             - Browse by Category
  - User Administration                          - Browse by Status
  - Categorization



Analysis

  - Step-debugging
  - Agenda Views and Inspection                  - Rule Authoring Analysis
  - Working Memory Inspection                    - Guided Test Audit Trails
  - Rule Engine Audit Trails




Tests
  - Technical Tests                              - Guided Tests
  - Technical Test Suites                        - Scenario Tests




Rules

  - Technical Rules (.drl)                       - Decision Tables
  - Enumerations
  - Domain Speciļ¬c Language                      - Decision Tables
  - Templates                                    - Guided Rules
  - Rule Flow                                    - English/Industry Speciļ¬c Rules



Facts

               Java Jars                                   Dynamic Facts



           Developer-centric                           Business Analyst


    Web-only Feature                               Modiļ¬able via Developer IDE

    Modiļ¬able via Web Browser or Developer IDE     Modiļ¬able via Excel/OpenOfļ¬ce
Deployment
  - Packaging
  - Snapshots                                    - Asset Search
  - Status Deļ¬nition                             - Browse by Category
  - User Administration                          - Browse by Status
  - Categorization



Analysis

  - Step-debugging
  - Agenda Views and Inspection                  - Rule Authoring Analysis
  - Working Memory Inspection                    - Guided Test Audit Trails
  - Rule Engine Audit Trails




Tests
  - Technical Tests                              - Guided Tests
  - Technical Test Suites                        - Scenario Tests




Rules

  - Technical Rules (.drl)                       - Decision Tables
  - Enumerations
  - Domain Speciļ¬c Language                      - Decision Tables
  - Templates                                    - Guided Rules
  - Rule Flow                                    - English/Industry Speciļ¬c Rules



Facts

               Java Jars                                   Dynamic Facts



           Developer-centric                           Business Analyst


    Web-only Feature                               Modiļ¬able via Developer IDE

    Modiļ¬able via Web Browser or Developer IDE     Modiļ¬able via Excel/OpenOfļ¬ce
Eclipse ā€“ Developer Perspective




                  43
Debugging
Debug Views




 lļ¬   New rule ā€œperspectiveā€ to configure IDE for rules as needed




                                  44
Guided Rule Editor (Eclipse)
Eclipse Guided Editor




                        45
Rule Flow




            46
Node Types
Domain Specific Process Steps


   ā€¢Extend Drools Flow to incorporate
     your applicationā€™s needs




Note: Community Only
Integrated Tooling
CEP
        Complex event processing


Real time events (concurrent events ā€“ thread
                   safe):


               sliding windows:
       Pattern(...) over window:time(3000)ā€«ā€ā€¬
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 Abstraction:
     ā€¢ Ability to compose complex events from atomic events

       AND reason over them
Events
ā€¢ (Usually) Immutable Facts
ā€¢ Strong Temporal
  Relationship

ā€¢ Managed Lifecylce
ā€¢ Use of sliding windows
ā€¢ Can provide metadata on:
 ā€¢ @timestamp, @duration or
   @expires
Streams
Temporal Reasoning
          ā€¢   Event and Time semantics:

              ā€¢   Point in Time

              ā€¢   Over an Interval

          ā€¢   Unified semantics for event
              correlation over time

          ā€¢   Temporal Constraints:

              ā€¢   Set of 13 operators to express
                  temporal relationship between
                  events
Expressive Event Constraints
                Point-Point   Point-Interval   Interval-Interval

 A before B

  A meets B

A overlaps B

A includes B

A finishes B

 A starts B

A coincides B
Behaviors & Sliding Windows
ā€¢ Behaviors: special semantics to certain patterns
  ā€¢   sliding windows, distinct, sort, etc

ā€¢ SlidingWindow: Allows reasoning over a moving
  window of ā€œinterestā€
  ā€¢   Time

  ā€¢   Length
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
ā€¢ Achieves coarse
  grained
  parallelization

ā€¢ No fundamental
  changes in the
  matching algorithm
  (ReteOO)

ā€¢ Preserves
  optimizations,
  especially node
  sharing
Planner
Note:
Not Yet
Supported!
What is Planner?
ā€¢Optimizes Automated Planning
ā€¢Use Cases:
 ā€¢ Space Planning
 ā€¢ Employee Shift Rostering
 ā€¢ Team Scheduling
ā€¢Still in development!
 ā€¢ Not commercially supported.
Hospital Admissions
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)
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 room
             BedDesignation(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 weight
end
Needle in a Haystack
Needle in a Haystack
          ā€¢ How many possible
            solutions?
            ā€¢   310 beds

                ā€¢   in 105 rooms

                ā€¢   in 4 departments

                ā€¢   84 nights
Needle in a Haystack
          ā€¢ How many possible
            solutions?
            ā€¢   310 beds

                ā€¢   in 105 rooms

                ā€¢   in 4 departments

                ā€¢   84 nights

          ā€¢ 2750 patients
            (admissions)
Needle in a Haystack
          ā€¢ How many possible
            solutions?
            ā€¢   310 beds

                ā€¢   in 105 rooms

                ā€¢   in 4 departments

                ā€¢   84 nights

          ā€¢ 2750 patients
            (admissions)

          ā€¢ Numbers from a real
            dataset
Commercial Support
ā€¢Drools ships within several supported
  platforms:
 ā€¢ JBoss Enterprise BRMS
 ā€¢ JBoss Enterprise SOA Platform *
 ā€¢ JBoss Enterprise Application Platform **
Support Open Source!
ā€¢   We need You!
    ā€¢   JBoss User Groups

    ā€¢   Contribute

        ā€¢   Code

        ā€¢   Features

        ā€¢   Documentation

        ā€¢   Testing

ā€¢ Let us continue our work that benefits so many.

More Related Content

What's hot

Ari Zilka Cluster Architecture Patterns
Ari Zilka Cluster Architecture PatternsAri Zilka Cluster Architecture Patterns
Ari Zilka Cluster Architecture Patterns
deimos
Ā 
Bertrand Delsart Java R T S
Bertrand Delsart Java R T SBertrand Delsart Java R T S
Bertrand Delsart Java R T S
deimos
Ā 
Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Grid
deimos
Ā 
Consolidated shared indexes in real time
Consolidated shared indexes in real timeConsolidated shared indexes in real time
Consolidated shared indexes in real time
Jeff Mace
Ā 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
Ā 
Gustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para TiGustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para Ti
Software Guru
Ā 
Understanding
Understanding Understanding
Understanding
Arun Gupta
Ā 

What's hot (20)

Ari Zilka Cluster Architecture Patterns
Ari Zilka Cluster Architecture PatternsAri Zilka Cluster Architecture Patterns
Ari Zilka Cluster Architecture Patterns
Ā 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with Unitils
Ā 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Ā 
Spring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuSpring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFu
Ā 
Bertrand Delsart Java R T S
Bertrand Delsart Java R T SBertrand Delsart Java R T S
Bertrand Delsart Java R T S
Ā 
Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Grid
Ā 
Orcale Presentation
Orcale PresentationOrcale Presentation
Orcale Presentation
Ā 
Successful DB migrations with Liquibase
 Successful DB migrations with Liquibase Successful DB migrations with Liquibase
Successful DB migrations with Liquibase
Ā 
Consolidated shared indexes in real time
Consolidated shared indexes in real timeConsolidated shared indexes in real time
Consolidated shared indexes in real time
Ā 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Ā 
Visage Android - Cleaner APIs, Cleaner UIs
Visage Android - Cleaner APIs, Cleaner UIsVisage Android - Cleaner APIs, Cleaner UIs
Visage Android - Cleaner APIs, Cleaner UIs
Ā 
Liquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseLiquibase - Open Source version control for your database
Liquibase - Open Source version control for your database
Ā 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
Ā 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the Cloud
Ā 
Gustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para TiGustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: EvoluciĆ³n de la Plataforma Java y lo que Significa para Ti
Ā 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Ā 
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
Ā 
Running your Java EE applications in the Cloud
Running your Java EE applications in the CloudRunning your Java EE applications in the Cloud
Running your Java EE applications in the Cloud
Ā 
Understanding
Understanding Understanding
Understanding
Ā 
Microsoft SQL Server Testing Frameworks
Microsoft SQL Server Testing FrameworksMicrosoft SQL Server Testing Frameworks
Microsoft SQL Server Testing Frameworks
Ā 

Viewers also liked

Jboss jbpm and drools 1 introduction to drools architecture
Jboss jbpm and drools   1 introduction to drools architectureJboss jbpm and drools   1 introduction to drools architecture
Jboss jbpm and drools 1 introduction to drools architecture
Zoran Hristov
Ā 
Open source and business rules
Open source and business rulesOpen source and business rules
Open source and business rules
Geoffrey De Smet
Ā 
Introduction to Drools
Introduction to DroolsIntroduction to Drools
Introduction to Drools
giurca
Ā 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorial
Srinath Perera
Ā 

Viewers also liked (20)

Drools 6 deep dive
Drools 6 deep diveDrools 6 deep dive
Drools 6 deep dive
Ā 
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTEJBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE
JBoss Drools and Drools Fusion (CEP): Making Business Rules react to RTE
Ā 
Decision Management : M2DL@UPS Lecture
Decision Management : M2DL@UPS LectureDecision Management : M2DL@UPS Lecture
Decision Management : M2DL@UPS Lecture
Ā 
jBPM
jBPMjBPM
jBPM
Ā 
Decision Service Architecture - Red Hat Forum Paris 2015
Decision Service Architecture - Red Hat Forum Paris 2015Decision Service Architecture - Red Hat Forum Paris 2015
Decision Service Architecture - Red Hat Forum Paris 2015
Ā 
DecisionsFrst Modeler and Red Hat JBoss BRMS
DecisionsFrst Modeler and Red Hat JBoss BRMSDecisionsFrst Modeler and Red Hat JBoss BRMS
DecisionsFrst Modeler and Red Hat JBoss BRMS
Ā 
Jboss jbpm and drools 1 introduction to drools architecture
Jboss jbpm and drools   1 introduction to drools architectureJboss jbpm and drools   1 introduction to drools architecture
Jboss jbpm and drools 1 introduction to drools architecture
Ā 
Open source and business rules
Open source and business rulesOpen source and business rules
Open source and business rules
Ā 
Introduction to Drools
Introduction to DroolsIntroduction to Drools
Introduction to Drools
Ā 
FOSS in the Enterprise
FOSS in the EnterpriseFOSS in the Enterprise
FOSS in the Enterprise
Ā 
Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013
Ā 
Apache Beam (incubating)
Apache Beam (incubating)Apache Beam (incubating)
Apache Beam (incubating)
Ā 
Drools BeJUG 2010
Drools BeJUG 2010Drools BeJUG 2010
Drools BeJUG 2010
Ā 
ieeecloud2016
ieeecloud2016ieeecloud2016
ieeecloud2016
Ā 
Drools5 Community Training Module 5 Drools BLIP Architectural Overview + Demos
Drools5 Community Training Module 5 Drools BLIP Architectural Overview + DemosDrools5 Community Training Module 5 Drools BLIP Architectural Overview + Demos
Drools5 Community Training Module 5 Drools BLIP Architectural Overview + Demos
Ā 
The Next Generation of Data Processing and Open Source
The Next Generation of Data Processing and Open SourceThe Next Generation of Data Processing and Open Source
The Next Generation of Data Processing and Open Source
Ā 
Drools & jBPM Info Sheet
Drools & jBPM Info SheetDrools & jBPM Info Sheet
Drools & jBPM Info Sheet
Ā 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorial
Ā 
JBoss BRMS sneak peak, the future is now for your Business Processes
JBoss BRMS sneak peak, the future is now for your Business ProcessesJBoss BRMS sneak peak, the future is now for your Business Processes
JBoss BRMS sneak peak, the future is now for your Business Processes
Ā 
Scio - A Scala API for Google Cloud Dataflow & Apache Beam
Scio - A Scala API for Google Cloud Dataflow & Apache BeamScio - A Scala API for Google Cloud Dataflow & Apache Beam
Scio - A Scala API for Google Cloud Dataflow & Apache Beam
Ā 

Similar to Intro to Drools - St Louis Gateway JUG

JBoss Enterprise Overview by Quinten Laureijs
JBoss Enterprise Overview by Quinten LaureijsJBoss Enterprise Overview by Quinten Laureijs
JBoss Enterprise Overview by Quinten Laureijs
Joram Barrez
Ā 
Advanced Application Lifecycle Managment
Advanced Application Lifecycle ManagmentAdvanced Application Lifecycle Managment
Advanced Application Lifecycle Managment
Salesforce Developers
Ā 
Testing in an Open Source Middleware Platform Space The WSO2 Way.
Testing in an Open Source Middleware Platform Space  The WSO2 Way.Testing in an Open Source Middleware Platform Space  The WSO2 Way.
Testing in an Open Source Middleware Platform Space The WSO2 Way.
WSO2
Ā 
QA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiously
QA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiouslyQA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiously
QA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiously
QAFest
Ā 

Similar to Intro to Drools - St Louis Gateway JUG (20)

JBoss BRMS - The enterprise platform for business logic
JBoss BRMS - The enterprise platform for business logicJBoss BRMS - The enterprise platform for business logic
JBoss BRMS - The enterprise platform for business logic
Ā 
JBPM Past Present Future
JBPM Past Present FutureJBPM Past Present Future
JBPM Past Present Future
Ā 
JBoss Enterprise Overview by Quinten Laureijs
JBoss Enterprise Overview by Quinten LaureijsJBoss Enterprise Overview by Quinten Laureijs
JBoss Enterprise Overview by Quinten Laureijs
Ā 
Advanced Application Lifecycle Managment
Advanced Application Lifecycle ManagmentAdvanced Application Lifecycle Managment
Advanced Application Lifecycle Managment
Ā 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an Introduction
Ā 
Testing in an Open Source Middleware Platform Space The WSO2 Way.
Testing in an Open Source Middleware Platform Space  The WSO2 Way.Testing in an Open Source Middleware Platform Space  The WSO2 Way.
Testing in an Open Source Middleware Platform Space The WSO2 Way.
Ā 
21st Century Service Oriented Architecture
21st Century Service Oriented Architecture21st Century Service Oriented Architecture
21st Century Service Oriented Architecture
Ā 
Testing Big Data solutions fast and furiously
Testing Big Data solutions fast and furiouslyTesting Big Data solutions fast and furiously
Testing Big Data solutions fast and furiously
Ā 
21st Century SOA
21st Century SOA21st Century SOA
21st Century SOA
Ā 
Design For Testability
Design For TestabilityDesign For Testability
Design For Testability
Ā 
Business processes, business rules, complex event processing, the JBoss way
Business processes, business rules, complex event processing, the JBoss wayBusiness processes, business rules, complex event processing, the JBoss way
Business processes, business rules, complex event processing, the JBoss way
Ā 
Session #1: Development Practices And The Microsoft Approach
Session #1: Development Practices And The Microsoft ApproachSession #1: Development Practices And The Microsoft Approach
Session #1: Development Practices And The Microsoft Approach
Ā 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
Ā 
Cloud-based Test Microservices JavaOne 2014
Cloud-based Test Microservices JavaOne 2014Cloud-based Test Microservices JavaOne 2014
Cloud-based Test Microservices JavaOne 2014
Ā 
Beginners overview of automated testing with Rspec
Beginners overview of automated testing with RspecBeginners overview of automated testing with Rspec
Beginners overview of automated testing with Rspec
Ā 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
Ā 
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
Ā 
DS, BP, EJB, CDI, WTF!? - Graham Charters
DS, BP, EJB, CDI, WTF!? - Graham ChartersDS, BP, EJB, CDI, WTF!? - Graham Charters
DS, BP, EJB, CDI, WTF!? - Graham Charters
Ā 
QA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiously
QA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiouslyQA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiously
QA Fest 2019. Š”Š¼ŠøтрŠøŠ¹ Š”Š¾Š±ŠŗŠ¾. Testing Big Data solutions fast and furiously
Ā 
Infrastructure as Code for Network
Infrastructure as Code for NetworkInfrastructure as Code for Network
Infrastructure as Code for Network
Ā 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
Ā 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
Ā 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
Ā 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
Ā 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Ā 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Ā 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Ā 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Ā 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Ā 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Ā 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Ā 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
Ā 
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Ā 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
Ā 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Ā 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
Ā 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Ā 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Ā 

Intro to Drools - St Louis Gateway JUG

  • 1. Ray Ploski Director - Developer Experience Drools and the BRMS The Business Logic Integration Platform
  • 2. Agenda ā€¢ The Concepts ā€¢ A Simple Example and Demo ā€¢ Projects Overview ā€¢ Best practices integrating Drools into your development process ā€¢ Learning more, getting involved and getting support
  • 3. What is Drools? Planner
  • 4.
  • 5. What is JBoss BRMS? JBoss Enterprise BRMS BRMS ā€¢ Single, integrated, certified distributions ā€¢ Extensive Q/A Process ā€¢ Industry-leading Support ā€¢ Documentation ā€¢ Secure, Production-level Configurations JBoss Runtime ā€¢ Multi-year Errata Policy A common and complete platform to model and govern the business logic of the enterprise
  • 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: 1 2 3 4 5 Delivery Phase Drools Projects Product Platform Testing, Platform Release Platform Component Requirements Certification & (General Availability) Engineering & Integration Definition Documentation Platform Quality JBoss Candidate BRMS Enterprise Productization Team Assurance Release(s) BRMS JBoss QA, Documentation JBoss Release JBoss Product Team, Certified Partners Engineering Productization Management Engineers JBoss.org Engineers 6
  • 8. The Typical SDLC View Layer Service Layer Business Layer Persistence Layer
  • 9. The Typical SDLC View Layer Service Layer Business Layer Persistence Layer
  • 10. The Typical SDLC View Layer Service Layer Business Layer Persistence Layer
  • 11. The Typical SDLC View Layer Service Layer Business Layer Persistence Layer
  • 12. The Typical SDLC View Layer Service Layer Business Layer Persistence Layer
  • 13. The Typical SDLC View Layer Service Layer Business Layer Persistence Layer
  • 14. The Typical SDLC View Layer Service Layer Business Layer Persistence Layer
  • 16. Extract the Logic ā€¢ Separate integration codebase from business logic and into a rules engine
  • 17. Extract the Logic ā€¢ Separate integration codebase from business logic and into a rules engine ā€¢ Goal: Remove the requirements churn and complexity
  • 18. Extract the Logic ā€¢ Separate integration codebase from business logic and into a rules engine ā€¢ Goal: Remove the requirements churn and complexity ā€¢ Goal: Empower your Domain Experts to directly author rules
  • 22. Business Logic ā€¢ Rules ā€¢ Process ā€¢ Response to Events
  • 23. Business Logic ā€¢ Rules ā€¢ Process ā€¢ Response to Events ā€¢ Planning Problems
  • 24. 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
  • 25. What is a Rules Engine?
  • 26. What is a Rules Engine? ā€¢ Ambiguous Term
  • 27. What is a Rules Engine? ā€¢ Ambiguous Term ā€¢ Inference Engine Concepts Clarify ā€¢ Scales to a large number of rules and facts ā€¢ Matches facts against rules to infer conclusions ā€¢ Conclusions result in actions rule ā€œXYZā€ when <conditions> ā€¢ Simple two-part structure: then <actions>
  • 28. Facts ā€¢ POJOs (Plain Old Java Objects) ā€¢ Rules engine uses to evaluate conditions ā€¢ Rules engine can execute POJO methods ā€¢ Can be loaded from a database via Hibernate, JPA, etc... ā€¢ Rules engine can modify a factā€™s state ā€¢ Dynamic Facts ā€¢ Can be modeled in the Web UI
  • 29. Facts ā€¢ POJOs (Plain Old Java Objects) ā€¢ Rules engine uses to evaluate conditions ā€¢ Rules engine can execute POJO methods ā€¢ Can be loaded from a database via Hibernate, JPA, etc... ā€¢ Rules engine can modify a factā€™s state ā€¢ Dynamic Facts ā€¢ Can be modeled in the Web UI
  • 30. Fact Model Example public class Room { Model is multiple private String name // getter and setter methods here facts and their } relationships public class Sprinkler { private Room room; private boolean on; // getter and setter methods here } public class Fire { private Room room; // getter and setter methods here } public class Alarm { }
  • 31. Fact Model Example public class Room { Model is multiple private String name // getter and setter methods here facts and their } relationships public class Sprinkler { private Room room; private boolean on; ā€¢ Must have setters/ // getter and setter methods here getters } public class Fire { ā€¢ Must have a public no-arg constructor private Room room; // getter and setter methods here ā€¢ No mandatory } inheritance/ public class Alarm { interface }
  • 32. Rules
  • 33. Rules ā€¢ Form the ā€œIF/Thenā€ action defined as ā€œWhen/Thenā€
  • 34. Rules ā€¢ Form the ā€œIF/Thenā€ action defined as ā€œWhen/Thenā€ ā€¢ Must have a name that is unique for a rule package
  • 35. 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
  • 36. 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
  • 37. 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
  • 38. 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
  • 39. 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!
  • 40. Rules in DRL package 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
  • 41. 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
  • 42. Rule Control ā— no-loop āœ“ short circuit rule recursion ā— salience āœ“ numeric value that represents rule importance ā— agenda-group āœ“ ļ¬re rules in group only when in focus ā— auto-focus āœ“ trigger focus change to the rule's agenda-group ā— activation-group āœ“ ļ¬rst matching rule ļ¬res āœ“ all other rules in group are ignored lock-on-active ā— date-effective, date-expires āœ“ deļ¬ne rules that are only active at certain points in time ā— template āœ“ deļ¬ne templates that may be reused in multiple rules
  • 43. Avenues for Authoring Rules - Dynamic Facts - Decision Tables - Guided Rules - English/Industry Speciļ¬c Rules - Guided Tests - Scenario Tests - Asset Search - Browse by Category - Browse by Status Web Broswer - Spreadsheet Decision Tables Spread sheet - Technical Rules (.drl) - Enumerations - Domain Speciļ¬c Language - Templates - Rule Flow - Step-debugging - Agenda Views and Inspection - Working Memory Inspection - Rule Engine Audit Trails - Technical Tests - Technical Test Suites JBoss Developer Studio
  • 44. BRMS ā€“ Rich UI for Business Rules 20
  • 46. Guided Rule Editor (Web) 22
  • 47. Web Decision Table Editor 23
  • 52. Multiple View / Edits in a Single Tab
  • 53. From, Collect & Accumulate Support From CE From Collect CE From Accumulate CE
  • 56. Fact Constraints within WorkingSets
  • 58. Runtime: Building private static 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); } throw new IllegalArgumentException("Could not parse knowledge."); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
  • 59. Runtime: Building private static 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); } throw new IllegalArgumentException("Could not parse knowledge."); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
  • 60. Runtime: Building private static 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); } throw new IllegalArgumentException("Could not parse knowledge."); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
  • 61. Runtime: Building private static 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); } throw new IllegalArgumentException("Could not parse knowledge."); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
  • 62. Runtime: Building private static 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); } throw new IllegalArgumentException("Could not parse knowledge."); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; }
  • 63. Camel & Spring Configuration <beansĀ xmlns="http://www.springframework.org/schema/beans" Ā Ā Ā Ā Ā Ā Ā xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Ā Ā Ā Ā Ā Ā Ā xmlns:drools="http://drools.org/schema/drools-spring"Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā Ā Ā Ā http://drools.org/schema/drools-springĀ http://verylongurl/drools-spring-1.0.0.xsd> Ā Ā <drools:resourceĀ id="resource1"Ā type="DRL"Ā source="classpath:orgth:org/drools/container/spring/testSpring.drl"/> Ā Ā <drools:kbaseĀ id="kbase1"> Ā Ā Ā Ā <drools:resources> Ā Ā Ā Ā Ā Ā <drools:resourceĀ type="DRL"Ā source="classpath:org/drools/container/spring/testSpring.drl"/> Ā Ā Ā Ā Ā Ā <drools:resourceĀ ref="resource1"/> Ā Ā Ā Ā Ā Ā <drools:resourceĀ source="classpath:org/drools/container/spring/IntegrationExampleTest.xls"Ā type="DTABLE"> Ā Ā Ā Ā Ā Ā Ā Ā <drools:decisiontable-confĀ input-type="XLS"Ā worksheet-name="Tables_2"Ā /> Ā Ā Ā Ā Ā Ā </drools:resource> Ā Ā Ā Ā </drools:resources> Ā Ā Ā Ā <drools:configuration> Ā Ā Ā Ā Ā Ā <drools:mbeansĀ enabled="true"Ā /> Ā Ā Ā Ā Ā Ā <drools:event-processing-modeĀ mode="STREAM"Ā /> Ā Ā Ā Ā </drools:configuration> Ā Ā </drools:kbase> </beans> THE BRE now has extensive Spring support, the XSD can be found in the the drools-spring jar. The namespace is "http://drools.org/schema/drools-spring"
  • 64. 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();
  • 65. 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();
  • 66. 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();
  • 67. 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();
  • 68. 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();
  • 69. 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();
  • 70. 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
  • 71. 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();
  • 72. 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 ofļ¬ce
  • 73. Runtime - Execution ksession.retract( kitchenFireHandle ); ksession.retract( officeFireHandle ); ksession.fireAllRules();
  • 74. Runtime - Execution ksession.retract( kitchenFireHandle ); ksession.retract( officeFireHandle ); ksession.fireAllRules(); > Turn off the sprinkler for room ofļ¬ce > Turn off the sprinkler for room kitchen > Cancel the alarm > Everything is ok
  • 75. 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
  • 76. Runtime Visibility - JMX ā€¢ Drools 5.3 brings support to the JMX standard and enables knowledge base and knowledge session monitoring and inspection using any JMX console. KnowledgeBase Stats
  • 77. Runtime Visibility - JMX KnowledgeSession Stats
  • 78. Deployment - Packaging - Snapshots - Asset Search - Status Deļ¬nition - Browse by Category - User Administration - Browse by Status - Categorization Analysis - Step-debugging - Agenda Views and Inspection - Rule Authoring Analysis - Working Memory Inspection - Guided Test Audit Trails - Rule Engine Audit Trails Tests - Technical Tests - Guided Tests - Technical Test Suites - Scenario Tests Rules - Technical Rules (.drl) - Decision Tables - Enumerations - Domain Speciļ¬c Language - Decision Tables - Templates - Guided Rules - Rule Flow - English/Industry Speciļ¬c Rules Facts Java Jars Dynamic Facts Developer-centric Business Analyst Web-only Feature Modiļ¬able via Developer IDE Modiļ¬able via Web Browser or Developer IDE Modiļ¬able via Excel/OpenOfļ¬ce
  • 79. Deployment - Packaging - Snapshots - Asset Search - Status Deļ¬nition - Browse by Category - User Administration - Browse by Status - Categorization Analysis - Step-debugging - Agenda Views and Inspection - Rule Authoring Analysis - Working Memory Inspection - Guided Test Audit Trails - Rule Engine Audit Trails Tests - Technical Tests - Guided Tests - Technical Test Suites - Scenario Tests Rules - Technical Rules (.drl) - Decision Tables - Enumerations - Domain Speciļ¬c Language - Decision Tables - Templates - Guided Rules - Rule Flow - English/Industry Speciļ¬c Rules Facts Java Jars Dynamic Facts Developer-centric Business Analyst Web-only Feature Modiļ¬able via Developer IDE Modiļ¬able via Web Browser or Developer IDE Modiļ¬able via Excel/OpenOfļ¬ce
  • 80. Deployment - Packaging - Snapshots - Asset Search - Status Deļ¬nition - Browse by Category - User Administration - Browse by Status - Categorization Analysis - Step-debugging - Agenda Views and Inspection - Rule Authoring Analysis - Working Memory Inspection - Guided Test Audit Trails - Rule Engine Audit Trails Tests - Technical Tests - Guided Tests - Technical Test Suites - Scenario Tests Rules - Technical Rules (.drl) - Decision Tables - Enumerations - Domain Speciļ¬c Language - Decision Tables - Templates - Guided Rules - Rule Flow - English/Industry Speciļ¬c Rules Facts Java Jars Dynamic Facts Developer-centric Business Analyst Web-only Feature Modiļ¬able via Developer IDE Modiļ¬able via Web Browser or Developer IDE Modiļ¬able via Excel/OpenOfļ¬ce
  • 81. Eclipse ā€“ Developer Perspective 43
  • 82. Debugging Debug Views lļ¬ New rule ā€œperspectiveā€ to configure IDE for rules as needed 44
  • 83. Guided Rule Editor (Eclipse) Eclipse Guided Editor 45
  • 84. Rule Flow 46
  • 86. Domain Specific Process Steps ā€¢Extend Drools Flow to incorporate your applicationā€™s needs Note: Community Only
  • 88. CEP Complex event processing Real time events (concurrent events ā€“ thread safe): sliding windows: Pattern(...) over window:time(3000)ā€«ā€ā€¬
  • 89. 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 Abstraction: ā€¢ Ability to compose complex events from atomic events AND reason over them
  • 90. Events ā€¢ (Usually) Immutable Facts ā€¢ Strong Temporal Relationship ā€¢ Managed Lifecylce ā€¢ Use of sliding windows ā€¢ Can provide metadata on: ā€¢ @timestamp, @duration or @expires
  • 92. Temporal Reasoning ā€¢ Event and Time semantics: ā€¢ Point in Time ā€¢ Over an Interval ā€¢ Unified semantics for event correlation over time ā€¢ Temporal Constraints: ā€¢ Set of 13 operators to express temporal relationship between events
  • 93. Expressive Event Constraints Point-Point Point-Interval Interval-Interval A before B A meets B A overlaps B A includes B A finishes B A starts B A coincides B
  • 94. Behaviors & Sliding Windows ā€¢ Behaviors: special semantics to certain patterns ā€¢ sliding windows, distinct, sort, etc ā€¢ SlidingWindow: Allows reasoning over a moving window of ā€œinterestā€ ā€¢ Time ā€¢ Length
  • 95. 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
  • 96. Rulebase Partitioning ā€¢ Achieves coarse grained parallelization ā€¢ No fundamental changes in the matching algorithm (ReteOO) ā€¢ Preserves optimizations, especially node sharing
  • 98. What is Planner? ā€¢Optimizes Automated Planning ā€¢Use Cases: ā€¢ Space Planning ā€¢ Employee Shift Rostering ā€¢ Team Scheduling ā€¢Still in development! ā€¢ Not commercially supported.
  • 100. 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)
  • 101. 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 room BedDesignation(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 weight end
  • 102. Needle in a Haystack
  • 103. Needle in a Haystack ā€¢ How many possible solutions? ā€¢ 310 beds ā€¢ in 105 rooms ā€¢ in 4 departments ā€¢ 84 nights
  • 104. Needle in a Haystack ā€¢ How many possible solutions? ā€¢ 310 beds ā€¢ in 105 rooms ā€¢ in 4 departments ā€¢ 84 nights ā€¢ 2750 patients (admissions)
  • 105. Needle in a Haystack ā€¢ How many possible solutions? ā€¢ 310 beds ā€¢ in 105 rooms ā€¢ in 4 departments ā€¢ 84 nights ā€¢ 2750 patients (admissions) ā€¢ Numbers from a real dataset
  • 106. Commercial Support ā€¢Drools ships within several supported platforms: ā€¢ JBoss Enterprise BRMS ā€¢ JBoss Enterprise SOA Platform * ā€¢ JBoss Enterprise Application Platform **
  • 107. Support Open Source! ā€¢ We need You! ā€¢ JBoss User Groups ā€¢ Contribute ā€¢ Code ā€¢ Features ā€¢ Documentation ā€¢ Testing ā€¢ Let us continue our work that benefits so many.