SlideShare a Scribd company logo
1 of 30
Change the title picture in the master




                                              Rules Engine :Drools

                                    Rule Engine Concepts and Drools Expert
Overview

•   Rule
•   Rule engine introduction & Working
•   Why use a Rule Engine?
•   ReteOO
•   Introduction to Drools
•   Drools Expert & Drools Rule Formats
•   Drools Rule Language Details
•   Drools Eclipse IDE &
•   Drools Guvnor Overview
•   Drools Flow Overview




2                          Rules Engine :Drools
Rule
 Rule                                                       Bean
    rule "Is of valid age"                                   public class Applicant {
      when
         $a : Applicant( age < 18 )           Constraints     private String name;
                                                               private int age;
      then                                                     private boolean valid;
         $a.setValid( false );                     Action
    end                                                      //getter and setter
                                                             methods here
                                                             }


 Constraints for above rule
       Object type constraint     - Applicant Object Type.
       Field constraints         - age < 18
 An object type constraint plus its zero or more field constraints is referred to as a
  pattern.
 The process of matching patterns against the inserted data is, referred to as
  pattern matching.


3                          Rules Engine :Drools
Rule Engine introduction & Working

The rule engine is the computer program that delivers Knowledge Representation
   and Reasoning(KRR) functionality to the developer. At a high level it has three
   components:
   Ontology (“Things” e.g java Classes/Beans )
   Rules
   Data




4                        Rules Engine :Drools
Why use a Rule Engine?


 Separates application from dynamic logic
    • Rules can be modified by different groups
    • No need to recompile or redeploy
    • All rules are in one place


 Declarative Programming
     – Readable and Anyone can easily modify rules.


 Centralization of Knowledge
    - Repository of business policy


 Speed and Scalability
    - Rete algorithm, Leaps algorithm



5                             Rules Engine :Drools
ReteOO

 Rete algorithm was invented by Dr. Charles Forgy.
 Rete algorithm can be broken into 2 parts: rule compilation and runtime
  execution.
 Rule base is compiled into discrimination network.
 Discrimination network is used to filter data as it propagates through the
  network.




6                       Rules Engine :Drools
Rete Algorithm example

rule 1
when
 Cheese( $cheddar : name == "cheddar" )
 $person : Person( favouriteCheese == $cheddar )
then
    System.out.println( $person.getName() + " likes cheddar" );
end




rule 2
when
 Cheese( $cheddar : name == "cheddar" )
 $person : Person( favouriteCheese != $cheddar )
then
    System.out.println( $person.getName() + " not likes cheddar" );
end




7                                    Rules Engine :Drools
Introduction to Drools & Drools Expert


 Drools 5 introduces the Business Logic integration Platform which provides a
  unified and integrated platform for Rules, Workflow and Event Processing.


 Drools consist out of several projects:
       Drools Expert (rule Engine)


       Drools Guvnor (Business Rule Manager)


       jBPM (Process/Workflow)


       Drools Fusion (event processing /temporal reasoning)


       Drools Planner (automated planning)




8                            Rules Engine :Drools
Drools Expert & Drools Rule Format

 Drools has an enhanced and optimized implementation of the Rete algorithm for
  object oriented systems called as ReteOO.
 Drools Expert is a declarative, rule based, coding environment.


 Drools Rule Formats
     Drools Rule Language (DRL)
     Domain-specific language (DSL)
     Decision tables
     Guided rule editor
     XML




9                          Rules Engine :Drools
Drools Rule Language(DRL)




10          Rules Engine :Drools
Domain-specific language (DSL)

 DSL are written in natural language statements.
 Domain experts (such as business analysts) can validate and do changes as per
  requirements.
 DSL definitions consists of transformations from DSL "sentences" to DRL
  constructs.
     DRL    Cheese(age < 5, price == 20, type=="stilton", country=="ch")

            [when]There is a Cheese with=Cheese()
     DSL    [when]- age is less than {age}=age<{age}
            [when]- type is '{type}'=type=='{type}‘
            [when]- country equal to '{country}'=country=='{country}'

            There is a Cheese with
     DSLR       - age is less than 42
                - type is 'stilton'

     DRL & DSL mapping

            [when]Something is {colour}=Something(colour=="{colour}")


11                        Rules Engine :Drools
Domain-specific language (DSL)




12           Rules Engine :Drools
Domain-specific language (DSLR)




13           Rules Engine :Drools
Decision table

 Decision tables are a "precise yet compact" (ref. Wikipedia) way of representing
  conditional logic, and are well suited to business level rules.
 spreadsheet format (XLS), and CSV.
 Decision tables are not recommended for rules that do not follow a set of
  templates, or where there are a small number of rules
 Each row in spreadsheet is a rule
 Decision tables are essentially a tool to generate DRL rules automatically




14                      Rules Engine :Drools
Decision tables




15            Rules Engine :Drools
Guided Rule Editor




16           Rules Engine :Drools
XML Rule Language




17          Rules Engine :Drools
Drools Rule Language :Executing Rules




18           Rules Engine :Drools
Drools Rule Language :Executing Rules

A Knowledge Base is what we call our collection of compiled definitions, such as
   rules and processes, which are compiled using the KnowledgeBuilder.


 First, we will create Knowledge Builder
     KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();


 Add DRL file to Knowledge Builder , it parses and compiles DRL files
     knowledgeBuilder.add(drlFileAsResource, ResourceType.DRL);


 If there are no errors, we can add the resulting packages to our Knowledge Base

     Collection pkgs = knowledgeBuilder.getKnowledgePackages();
     knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
     knowledgeBase.addKnowledgePackages(pkgs);




19                            Rules Engine :Drools
Drools Rule Language :Executing Rules

 KnowledgeSession provides the way of exposing objects to be ruled.
 Stateless Knowledge Session

     StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
     Applicant applicant = new Applicant( “Rajesh Kumar", 16 );
     ksession.execute( applicant );
     assertFalse( applicant.isValid() );



 Stateful Knowledge Session

     StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
     Applicant applicant = new Applicant( “Rajesh Kumar", 16 );
     knowledgeSession.insert(applicant);
     knowledgeSession.fireAllRules();




20                             Rules Engine :Drools
Drools Rule Language


Knowledge base can be updated inside rule’s body
 insert()
      Inserted object will be used by rules engines inside current session
 update()
      Updates existing in working memory object for the rest of rules
 delete()
      Removed object will not be ruled on current execution




21                         Rules Engine :Drools
Drools Eclipse IDE

 The Eclipse based IDE provides users with an environment to edit and test rules
  in various formats, and integrate it deeply with their applications.
 Required plugins
        GEF plugin , GEF is the Eclipse Graphical Editing Framework.
         http://download.eclipse.org/tools/gef/updates/releases/
        Drools Eclipse IDE plugin
         http://download.jboss.org/drools/release/5.4.0.Final/org.drools.updatesite/
 Defining a Drools Runtime
        Go to windows preferences
        under the Drools category,
         select "Installed Drools runtimes“
        use the default jar files as included in
         the Drools Eclipse plugin
         by clicking "Create a new Drools 5 runtime"



22                            Rules Engine :Drools
23   Rules Engine :Drools
Drools Guvnor Overview


 Web-based rule management, storage, editing and deployment
  environment.
 Rule editing
      text, guided, decision tables, etc.
 Version control
 Categorization
 Build and deploy
 Scenarios




24                     Rules Engine :Drools
Guvnor Rule Editing




25           Rules Engine :Drools
Guvnor Rule Deployment




26          Rules Engine :Drools
Guvnor Test Scenarios




27           Rules Engine :Drools
Drools Flow Overview




28           Rules Engine :Drools
References

 Drools Homepage
     http://www.jboss.org/drools/
 Drools Blog
     http://blog.athico.com/
 Drools Chat
     irc.codehaus.org #drools
 Drools Mailing List
     rules-users@lists.jboss.org




29                        Rules Engine :Drools
Thank you


     Any questions?



30         Rules Engine :Drools

More Related Content

What's hot

Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First ExampleDrools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First ExampleMauricio (Salaboy) Salatino
 
Rule Engine: Drools .Net
Rule Engine: Drools .NetRule Engine: Drools .Net
Rule Engine: Drools .NetGuo Albert
 
Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)martincabrera
 
Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)Mark Proctor
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Michel Schudel
 
Drools Expert and Fusion Intro : London 2012
Drools Expert and Fusion Intro  : London 2012Drools Expert and Fusion Intro  : London 2012
Drools Expert and Fusion Intro : London 2012Mark Proctor
 
Mastering the MongoDB Shell
Mastering the MongoDB ShellMastering the MongoDB Shell
Mastering the MongoDB ShellMongoDB
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBLee Theobald
 
Low Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesLow Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesTanel Poder
 
Model Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON StructuresModel Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON StructuresMarkus Lanthaler
 
Best Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVBest Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVICS
 
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?SegFaultConf
 
Introduction to Cassandra Architecture
Introduction to Cassandra ArchitectureIntroduction to Cassandra Architecture
Introduction to Cassandra Architecturenickmbailey
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance TuningGunnar Hillert
 
SQL-on-Hadoop Tutorial
SQL-on-Hadoop TutorialSQL-on-Hadoop Tutorial
SQL-on-Hadoop TutorialDaniel Abadi
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql DatabasePrashant Gupta
 
Oracle Database In-Memory Advisor (English)
Oracle Database In-Memory Advisor (English)Oracle Database In-Memory Advisor (English)
Oracle Database In-Memory Advisor (English)Ileana Somesan
 
Microservices with Apache Camel
Microservices with Apache CamelMicroservices with Apache Camel
Microservices with Apache CamelClaus Ibsen
 

What's hot (20)

Drools
DroolsDrools
Drools
 
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First ExampleDrools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
 
Rule Engine: Drools .Net
Rule Engine: Drools .NetRule Engine: Drools .Net
Rule Engine: Drools .Net
 
Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)
 
Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
 
Drools Expert and Fusion Intro : London 2012
Drools Expert and Fusion Intro  : London 2012Drools Expert and Fusion Intro  : London 2012
Drools Expert and Fusion Intro : London 2012
 
Mastering the MongoDB Shell
Mastering the MongoDB ShellMastering the MongoDB Shell
Mastering the MongoDB Shell
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
 
A Step Towards Data Orientation
A Step Towards Data OrientationA Step Towards Data Orientation
A Step Towards Data Orientation
 
Low Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesLow Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling Examples
 
Model Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON StructuresModel Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON Structures
 
Best Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVBest Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IV
 
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
 
Introduction to Cassandra Architecture
Introduction to Cassandra ArchitectureIntroduction to Cassandra Architecture
Introduction to Cassandra Architecture
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
 
SQL-on-Hadoop Tutorial
SQL-on-Hadoop TutorialSQL-on-Hadoop Tutorial
SQL-on-Hadoop Tutorial
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
 
Oracle Database In-Memory Advisor (English)
Oracle Database In-Memory Advisor (English)Oracle Database In-Memory Advisor (English)
Oracle Database In-Memory Advisor (English)
 
Microservices with Apache Camel
Microservices with Apache CamelMicroservices with Apache Camel
Microservices with Apache Camel
 

Similar to Rule Engine & Drools

Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Geoffrey De Smet
 
DFDL and Apache Daffodil(tm) Overview from Owl Cyber Defense
DFDL and Apache Daffodil(tm) Overview from Owl Cyber DefenseDFDL and Apache Daffodil(tm) Overview from Owl Cyber Defense
DFDL and Apache Daffodil(tm) Overview from Owl Cyber DefenseMike Beckerle
 
JBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic PlatformJBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic Platformelliando dias
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital.AI
 
Controller design-pattern-drupal-north-toronto-2018-final
Controller design-pattern-drupal-north-toronto-2018-finalController design-pattern-drupal-north-toronto-2018-final
Controller design-pattern-drupal-north-toronto-2018-finalVic Tarchenko
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)lennartkats
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBMartin Grebac
 
Domains - Don't leave your data model without them
Domains - Don't leave your data model without themDomains - Don't leave your data model without them
Domains - Don't leave your data model without themPeter Heller
 
Integrating DROOLS With Mule ESB
Integrating DROOLS With Mule ESBIntegrating DROOLS With Mule ESB
Integrating DROOLS With Mule ESBJitendra Bafna
 
RELAX NG to DTD and XSD Using the Open Toolkit
RELAX NG to DTD and XSD Using the Open ToolkitRELAX NG to DTD and XSD Using the Open Toolkit
RELAX NG to DTD and XSD Using the Open ToolkitContrext Solutions
 
NoSQL no more: SQL on Druid with Apache Calcite
NoSQL no more: SQL on Druid with Apache CalciteNoSQL no more: SQL on Druid with Apache Calcite
NoSQL no more: SQL on Druid with Apache Calcitegianmerlino
 
Develop an App with the Odoo Framework
Develop an App with the Odoo FrameworkDevelop an App with the Odoo Framework
Develop an App with the Odoo FrameworkOdoo
 
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019Dave Stokes
 
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...Dave Stokes
 
Rules SDK IBM WW BPM Forum March 2013
Rules SDK IBM WW BPM Forum March 2013Rules SDK IBM WW BPM Forum March 2013
Rules SDK IBM WW BPM Forum March 2013Dan Selman
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the CloudJim Driscoll
 

Similar to Rule Engine & Drools (20)

Rules With Drools
Rules With DroolsRules With Drools
Rules With Drools
 
Rules with Drools
Rules with DroolsRules with Drools
Rules with Drools
 
Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)
 
DFDL and Apache Daffodil(tm) Overview from Owl Cyber Defense
DFDL and Apache Daffodil(tm) Overview from Owl Cyber DefenseDFDL and Apache Daffodil(tm) Overview from Owl Cyber Defense
DFDL and Apache Daffodil(tm) Overview from Owl Cyber Defense
 
JBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic PlatformJBoss Drools - Open-Source Business Logic Platform
JBoss Drools - Open-Source Business Logic Platform
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
 
JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...
JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...
JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...
 
Controller design-pattern-drupal-north-toronto-2018-final
Controller design-pattern-drupal-north-toronto-2018-finalController design-pattern-drupal-north-toronto-2018-final
Controller design-pattern-drupal-north-toronto-2018-final
 
OpenDDR
OpenDDROpenDDR
OpenDDR
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXB
 
Domains - Don't leave your data model without them
Domains - Don't leave your data model without themDomains - Don't leave your data model without them
Domains - Don't leave your data model without them
 
Integrating DROOLS With Mule ESB
Integrating DROOLS With Mule ESBIntegrating DROOLS With Mule ESB
Integrating DROOLS With Mule ESB
 
RELAX NG to DTD and XSD Using the Open Toolkit
RELAX NG to DTD and XSD Using the Open ToolkitRELAX NG to DTD and XSD Using the Open Toolkit
RELAX NG to DTD and XSD Using the Open Toolkit
 
NoSQL no more: SQL on Druid with Apache Calcite
NoSQL no more: SQL on Druid with Apache CalciteNoSQL no more: SQL on Druid with Apache Calcite
NoSQL no more: SQL on Druid with Apache Calcite
 
Develop an App with the Odoo Framework
Develop an App with the Odoo FrameworkDevelop an App with the Odoo Framework
Develop an App with the Odoo Framework
 
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019
 
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
 
Rules SDK IBM WW BPM Forum March 2013
Rules SDK IBM WW BPM Forum March 2013Rules SDK IBM WW BPM Forum March 2013
Rules SDK IBM WW BPM Forum March 2013
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the Cloud
 

Recently uploaded

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 

Recently uploaded (20)

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 

Rule Engine & Drools

  • 1. Change the title picture in the master Rules Engine :Drools Rule Engine Concepts and Drools Expert
  • 2. Overview • Rule • Rule engine introduction & Working • Why use a Rule Engine? • ReteOO • Introduction to Drools • Drools Expert & Drools Rule Formats • Drools Rule Language Details • Drools Eclipse IDE & • Drools Guvnor Overview • Drools Flow Overview 2 Rules Engine :Drools
  • 3. Rule  Rule Bean rule "Is of valid age" public class Applicant { when $a : Applicant( age < 18 )  Constraints private String name; private int age; then private boolean valid; $a.setValid( false );  Action end //getter and setter methods here }  Constraints for above rule Object type constraint - Applicant Object Type. Field constraints - age < 18  An object type constraint plus its zero or more field constraints is referred to as a pattern.  The process of matching patterns against the inserted data is, referred to as pattern matching. 3 Rules Engine :Drools
  • 4. Rule Engine introduction & Working The rule engine is the computer program that delivers Knowledge Representation and Reasoning(KRR) functionality to the developer. At a high level it has three components:  Ontology (“Things” e.g java Classes/Beans )  Rules  Data 4 Rules Engine :Drools
  • 5. Why use a Rule Engine?  Separates application from dynamic logic • Rules can be modified by different groups • No need to recompile or redeploy • All rules are in one place  Declarative Programming – Readable and Anyone can easily modify rules.  Centralization of Knowledge - Repository of business policy  Speed and Scalability - Rete algorithm, Leaps algorithm 5 Rules Engine :Drools
  • 6. ReteOO  Rete algorithm was invented by Dr. Charles Forgy.  Rete algorithm can be broken into 2 parts: rule compilation and runtime execution.  Rule base is compiled into discrimination network.  Discrimination network is used to filter data as it propagates through the network. 6 Rules Engine :Drools
  • 7. Rete Algorithm example rule 1 when Cheese( $cheddar : name == "cheddar" ) $person : Person( favouriteCheese == $cheddar ) then System.out.println( $person.getName() + " likes cheddar" ); end rule 2 when Cheese( $cheddar : name == "cheddar" ) $person : Person( favouriteCheese != $cheddar ) then System.out.println( $person.getName() + " not likes cheddar" ); end 7 Rules Engine :Drools
  • 8. Introduction to Drools & Drools Expert  Drools 5 introduces the Business Logic integration Platform which provides a unified and integrated platform for Rules, Workflow and Event Processing.  Drools consist out of several projects: Drools Expert (rule Engine) Drools Guvnor (Business Rule Manager) jBPM (Process/Workflow) Drools Fusion (event processing /temporal reasoning) Drools Planner (automated planning) 8 Rules Engine :Drools
  • 9. Drools Expert & Drools Rule Format  Drools has an enhanced and optimized implementation of the Rete algorithm for object oriented systems called as ReteOO.  Drools Expert is a declarative, rule based, coding environment.  Drools Rule Formats  Drools Rule Language (DRL)  Domain-specific language (DSL)  Decision tables  Guided rule editor  XML 9 Rules Engine :Drools
  • 10. Drools Rule Language(DRL) 10 Rules Engine :Drools
  • 11. Domain-specific language (DSL)  DSL are written in natural language statements.  Domain experts (such as business analysts) can validate and do changes as per requirements.  DSL definitions consists of transformations from DSL "sentences" to DRL constructs. DRL Cheese(age < 5, price == 20, type=="stilton", country=="ch") [when]There is a Cheese with=Cheese() DSL [when]- age is less than {age}=age<{age} [when]- type is '{type}'=type=='{type}‘ [when]- country equal to '{country}'=country=='{country}' There is a Cheese with DSLR - age is less than 42 - type is 'stilton' DRL & DSL mapping [when]Something is {colour}=Something(colour=="{colour}") 11 Rules Engine :Drools
  • 12. Domain-specific language (DSL) 12 Rules Engine :Drools
  • 13. Domain-specific language (DSLR) 13 Rules Engine :Drools
  • 14. Decision table  Decision tables are a "precise yet compact" (ref. Wikipedia) way of representing conditional logic, and are well suited to business level rules.  spreadsheet format (XLS), and CSV.  Decision tables are not recommended for rules that do not follow a set of templates, or where there are a small number of rules  Each row in spreadsheet is a rule  Decision tables are essentially a tool to generate DRL rules automatically 14 Rules Engine :Drools
  • 15. Decision tables 15 Rules Engine :Drools
  • 16. Guided Rule Editor 16 Rules Engine :Drools
  • 17. XML Rule Language 17 Rules Engine :Drools
  • 18. Drools Rule Language :Executing Rules 18 Rules Engine :Drools
  • 19. Drools Rule Language :Executing Rules A Knowledge Base is what we call our collection of compiled definitions, such as rules and processes, which are compiled using the KnowledgeBuilder.  First, we will create Knowledge Builder KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();  Add DRL file to Knowledge Builder , it parses and compiles DRL files knowledgeBuilder.add(drlFileAsResource, ResourceType.DRL);  If there are no errors, we can add the resulting packages to our Knowledge Base Collection pkgs = knowledgeBuilder.getKnowledgePackages(); knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); knowledgeBase.addKnowledgePackages(pkgs); 19 Rules Engine :Drools
  • 20. Drools Rule Language :Executing Rules  KnowledgeSession provides the way of exposing objects to be ruled.  Stateless Knowledge Session StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); Applicant applicant = new Applicant( “Rajesh Kumar", 16 ); ksession.execute( applicant ); assertFalse( applicant.isValid() );  Stateful Knowledge Session StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); Applicant applicant = new Applicant( “Rajesh Kumar", 16 ); knowledgeSession.insert(applicant); knowledgeSession.fireAllRules(); 20 Rules Engine :Drools
  • 21. Drools Rule Language Knowledge base can be updated inside rule’s body  insert()  Inserted object will be used by rules engines inside current session  update()  Updates existing in working memory object for the rest of rules  delete()  Removed object will not be ruled on current execution 21 Rules Engine :Drools
  • 22. Drools Eclipse IDE  The Eclipse based IDE provides users with an environment to edit and test rules in various formats, and integrate it deeply with their applications.  Required plugins  GEF plugin , GEF is the Eclipse Graphical Editing Framework. http://download.eclipse.org/tools/gef/updates/releases/  Drools Eclipse IDE plugin http://download.jboss.org/drools/release/5.4.0.Final/org.drools.updatesite/  Defining a Drools Runtime  Go to windows preferences  under the Drools category, select "Installed Drools runtimes“  use the default jar files as included in the Drools Eclipse plugin by clicking "Create a new Drools 5 runtime" 22 Rules Engine :Drools
  • 23. 23 Rules Engine :Drools
  • 24. Drools Guvnor Overview  Web-based rule management, storage, editing and deployment environment.  Rule editing  text, guided, decision tables, etc.  Version control  Categorization  Build and deploy  Scenarios 24 Rules Engine :Drools
  • 25. Guvnor Rule Editing 25 Rules Engine :Drools
  • 26. Guvnor Rule Deployment 26 Rules Engine :Drools
  • 27. Guvnor Test Scenarios 27 Rules Engine :Drools
  • 28. Drools Flow Overview 28 Rules Engine :Drools
  • 29. References  Drools Homepage http://www.jboss.org/drools/  Drools Blog http://blog.athico.com/  Drools Chat irc.codehaus.org #drools  Drools Mailing List rules-users@lists.jboss.org 29 Rules Engine :Drools
  • 30. Thank you Any questions? 30 Rules Engine :Drools