SlideShare une entreprise Scribd logo
1  sur  69
Fernando Meyer
fmeyer@codehaus.org
    www.jboss.org
   www.fmeyer.org
Project history
JBoss/Red Hat
History of Rule Engines
                     70s: Mycin/E-Mycin
               80s: CLIPS + many more
                       (expert systems)‫‏‬
             90s: BRMS (Ilog, Fair Isaac)‫‏‬
           (business rules management)‫‏‬
Practical rule engines
             Humorous introduction
            Thanks to Thomas Meeks
                (it tries to be funny)‫‏‬
What are rule engines
        for?
          Add rules == expert system
   (a system that emulates a domain expert)‫‏‬

  BRMS == Business Rule Management System
(central management of changing business rules)‫‏‬

              Decision services
    (automated decisions, decision support)‫‏‬
No really?
          What are they good for?
             Some example users:

    HR (coping with multiple awards)‫‏‬
      Transport (monitoring sensors)‫‏‬
   Mortgage products (> 4000 rules)‫‏‬
Drools is an engine++
 IDE (developer tooling) – debugging
 Web based tooling (analysis – BRMS)‫‏‬
 Deployment tools
 CEP/Stream processing (future)‫‏‬
 Testing and analysis tools (next release)‫‏‬
 Multiple authoring paradigms:
 DRL, DSL, XLS (decision tables), PNL, Rule Flow
A quick visual tour...
IDE
Web tools:
rule editing
DSLs for i18n
Integrated testing
Logic Analysis
Climbing the peak...
            Helps simplify complicated logic
   Lowers the cost of changing business logic
                             Usually very fast
        Basically a business logic framework
Not another
framework !
No silver bullet
Rule engines are a complexity, use only as needed,
                otherwise, grrr.....
So, when to use one?
Complicated logic (not 1+1 = 3 for large values of 1)‫‏‬
Changes often (whatever that means)‫‏‬
Traditional approaches are a challenge
Domain expertise is readily available
Don't use for a
          shopping cart
Don't use on applications with simple business
logic

If the logic is complicated but will never (ever)
change, might not need it.

Easy logic, changes often?
        try : Scripting, Lookup tables etc...
Optimisation and speed
RETE
Latin for “net”.
As in network, or graph.

Performance is theoretically independent of the number
of rules in the system.

Hint: its really a stateful optimisation technique, no-one
expects you to know it (or care).
Example
Lets use rules to solve a real world scenario




   Well, real, perhaps if you are a pirate
A Domain expert
   Yarr, Launch every ZIG !



   (Captn' Domain Expert)‫‏‬
if (us.somebodySetUsUpTheBomb()) {
  for (Zig zig : us.getZigs()) {
    zig.launch(); // for justice!
  }
}
Sally the Mechanic
           Zigs should not launch
            without their weapon
                         system...
Which of course are...
                Atomic Kittens
if (us.somebodySetUsUpTheBomb()) {
  for (Zig zig : us.getZigs()) {
    if (zig.hasAtomicKitty()) {
      zig.launch();
    }
  }
}
Johnny the Regulator
       Zigs must have been inspected in
          the last 24 hours to launch!
if (us.somebodySetUsUpTheBomb()) {
  for (Zig zig : us.getZigs()) {
    if (zig.hasAtomicKitty()‫‏‬
        && zig.isInspected()) {
      zig.launch();
    }
  }
}
Johnny the Regulator
         Oh, and rule 23.43-57a#32.57
       explicitly states that no more than
            10 Zigs can fly at a time!
if (us.somebodySetUsUpTheBomb()) {
  int i = 0;
  for (Zig zig : us.getZigs()) {
    if (i == 10) {
      break;
    }
    if (zig.hasAtomicKitty()‫‏‬
        && zig.inspected()) {
      zig.launch();
      i++;
    }
  }
}
Capt'n Domain expert
       Arr! Only 10!?
       If a Zig be shot down, launch more!
Hmmm...
We could keep checking every Zig's status in an infinite
loop.

We could implement the observer pattern on Zigs
(when they explode, they tell someone).
etc... <snore>

Lets stick with the loop for the example
int i = 0;
while (us.somebodySetUsUpTheBomb()) {
  for (Zig zig : us.getZigs()) {
    if (zig.hasExploded()) {
      us.getZigs().remove(zig);
      i--;
      continue;
    }
    if (zig.hasAtomicKitty() && zig.inspected()‫‏‬
        && i < 10) {
      zig.launch();
      i++;
    }
  }
}
Sally the Mechanic
          If those Zigs get beat
          up, they should land
          so I can fix them!

          And don't try to
          launch them while
          I'm working on them!
int i = 0;
   while (somebodySetUsUpTheBomb()) {
     for (Zig zig : us.getZigs()) {
       if (zig.needsMaintenance()) {
         zig.land();
         mechanic.startFixing(zig);
         i--;
         continue;
       }
       if (zig.hasExploded()) {
         us.getZigs().remove(zig);
         i--;
         continue;
       }
       if (zig.hasAtomicKitty() && zig.inspected()‫‏‬
           && i < 10 && !zig.inMaintenance()) {
         zig.launch();
         i++;
       }
     }
   }




Hint: Most likely “inMaintenance” check will be forgotten,
the first time....
Johnny the Regulator
          I forgot to mention that rule
       23.43-57a#32.57a explicitly states
       that all Zigs can fly if you fax form
           453.438-347#B in triplicate
Capt'n Domain expert
         Arr! That form takes hours to fill!
      Arr! Launch 10 until we fax it, then Take
                   off every Zig!
int i = 0;
while (somebodySetUsUpTheBomb()) {
  form.asyncFillOutAndFax();
    for (Zig zig : us.getZigs()) {
      if (zig.needsMaintenance()) {
        zig.land();
        mechanic.startFixing(zig);
        i--;
        continue;
      }
      if (zig.hasExploded()) {
        us.getZigs().remove(zig);
        i--;
        continue;
      }
      if (zig.hasAtomicKitty() && zig.inspected()‫‏‬
          && (i < 10 || form.isFaxed()) && !zig.inMaintenance()) {
        zig.launch();
        i++;
      }
    }
}
Johnny the Regulator
        We just changed the rules!
        All Zigs must be pink to fly
Sally the Mechanic
          Paint them pink!?
          That will take
          months! We have
          thousands!
Capt'n Domain expert
            Arr! Take off all pink Zigs!
       If we finish painting a Zig, launch it!
Getting complicated?
 Thousands of Zigs? That loop could take a while

                      A lot of event-driven logic

     Looks like it is going to end up really messy

                  No, the regulator will not stop
Wait a second...
You might be thinking – that was awfully arbitrary!

Or – Hey, I can make up stupid requirements that are
hard to implement in a huge loop cleanly too!

I must assume you aren't in a regulated industry...
Now, using rules...
rule “take off every zig (for great justice)”
  no-loop true;
  when
    Us(somebodySetUpUsTheBomb == true)‫‏‬
    zig : Zig(inspected == true,
              pink == true,
              atomicKitten == true,
              inMaintenance == false,
              launched == false)‫‏‬
    launched : launched(launched < 10
                        || formFaxed == true)‫‏‬
  then
    zig.launch()‫‏‬
    launched.increment()‫‏‬
    update(zig)‫‏‬
    update(launched)‫‏‬
end
rule “zig explodes”
  no-loop true
  when
    zig : Zig(destroyed == true)‫‏‬
    launched : Launched()‫‏‬
  then
    retract(zig)‫‏‬
    launched.decrement()‫‏‬
    update(launched)‫‏‬
end
rule “repair zig”
  no-loop true
  when
    zig : Zig(needsMaintenance == true)‫‏‬
    mechanic : Mechanic()‫‏‬
    launched : Launched()‫‏‬
  then
    zig.land();
    launched.decrement();
    mechanic.startFixing(zig); //update zig when done
    update(zig);
end
Where is the loop?
                        Implied

Each rule fires for each fact combination that matches

If you “assert” (insert) 1000 Zigs, the first rule will be
                  checked 1000 times
 (but it remembers, indexes, for future data changes)‫‏‬
What else is good
New rules can be gracefully inserted
into a large ruleset (even while running)‫‏‬

Will automatically fire when conditions are met

Caching facts makes execution very fast

Properly managed rules can create very dynamic
systems
The trough of
          disillusionment
Easy to overuse rules

Not all logic (even in complex systems) should be in
rules

Notice that there is no rule describing how a Zig
launches

Bugs in overly complex rules can be evil
Java bug
C Bug
Rules Bug
A quick aside on
 choosing a rule engine..
It needs to have a NOT conditional
(e.g. Operate on the non-existence of a fact)‫‏‬

Don't trust claims of graphical programming
It is neat, but not a silver bullet

Ditto for “end user computing”

Be realistic
Deployment models
Decision service
       -Typically a web service (centrally hosted)‫‏‬

Embedded into an application

Central BRMS server
Some standards
   Java API: JSR94 *
     SBVR (OMG)
        RuleML
     RIF (W3C) *
Other products
Ilog JRules
Fair Isaac Blaze Advisor
Corticon
 -interesting spreadsheet based rule modelling
RuleBurst (now Haley)‫‏‬
 -specialise in natural language and rules extracted from
documentation
Roadmap for 2008
                 CEP
 Testing & Analysis (Automated QA)‫‏‬
     Integrated processes (BPM)‫‏‬
 “process server” (decision services)‫‏‬
Thanks !
fernando.meyer@redhat.com
       www.jboss.org

Read the blog: blog.athico.com
    Me: www.fmeyer.org
       Thanks Michael

Contenu connexe

En vedette

Search Intelligence @elo7.com
Search Intelligence @elo7.comSearch Intelligence @elo7.com
Search Intelligence @elo7.comFernando Meyer
 
Computação aplicada na boo-box
Computação aplicada na boo-boxComputação aplicada na boo-box
Computação aplicada na boo-boxFernando Meyer
 
Palestra encontro provedores regionais recife agosto 20 2013 eduardo grizeni...
Palestra encontro provedores regionais recife  agosto 20 2013 eduardo grizeni...Palestra encontro provedores regionais recife  agosto 20 2013 eduardo grizeni...
Palestra encontro provedores regionais recife agosto 20 2013 eduardo grizeni...Eduardo Grizendi
 

En vedette (8)

Jboss Night
Jboss NightJboss Night
Jboss Night
 
Antlr Conexaojava
Antlr ConexaojavaAntlr Conexaojava
Antlr Conexaojava
 
Search Intelligence @elo7.com
Search Intelligence @elo7.comSearch Intelligence @elo7.com
Search Intelligence @elo7.com
 
Computação aplicada na boo-box
Computação aplicada na boo-boxComputação aplicada na boo-box
Computação aplicada na boo-box
 
Palestra encontro provedores regionais recife agosto 20 2013 eduardo grizeni...
Palestra encontro provedores regionais recife  agosto 20 2013 eduardo grizeni...Palestra encontro provedores regionais recife  agosto 20 2013 eduardo grizeni...
Palestra encontro provedores regionais recife agosto 20 2013 eduardo grizeni...
 
Nemesis Project
Nemesis Project Nemesis Project
Nemesis Project
 
Qcon bigdata
Qcon bigdataQcon bigdata
Qcon bigdata
 
Big data analytics
Big data analyticsBig data analytics
Big data analytics
 

Similaire à Drools Fisl

Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Appsadunne
 
OpenGL L02-Transformations
OpenGL L02-TransformationsOpenGL L02-Transformations
OpenGL L02-TransformationsMohammad Shaker
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor ConcurrencyAlex Miller
 
Static analysis of C++ source code
Static analysis of C++ source codeStatic analysis of C++ source code
Static analysis of C++ source codePVS-Studio
 
Static analysis of C++ source code
Static analysis of C++ source codeStatic analysis of C++ source code
Static analysis of C++ source codeAndrey Karpov
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
HAB Software Woes
HAB Software WoesHAB Software Woes
HAB Software Woesjgrahamc
 
Non stop random2b
Non stop random2bNon stop random2b
Non stop random2bphanhung20
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testingFoundationDB
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market OpenAzul Systems Inc.
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend TestingNeil Crosby
 
Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)William Farrell
 
The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196Mahmoud Samir Fayed
 
How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...Mario Fusco
 
Ajax World Comet Talk
Ajax World Comet TalkAjax World Comet Talk
Ajax World Comet Talkrajivmordani
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerJAX London
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Michael Barker
 
Back To The Future.Key 2
Back To The Future.Key 2Back To The Future.Key 2
Back To The Future.Key 2gueste8cc560
 

Similaire à Drools Fisl (20)

Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Apps
 
OpenGL L02-Transformations
OpenGL L02-TransformationsOpenGL L02-Transformations
OpenGL L02-Transformations
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
 
Static analysis of C++ source code
Static analysis of C++ source codeStatic analysis of C++ source code
Static analysis of C++ source code
 
Static analysis of C++ source code
Static analysis of C++ source codeStatic analysis of C++ source code
Static analysis of C++ source code
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
HAB Software Woes
HAB Software WoesHAB Software Woes
HAB Software Woes
 
Non stop random2b
Non stop random2bNon stop random2b
Non stop random2b
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Mgd08 lab01
Mgd08 lab01Mgd08 lab01
Mgd08 lab01
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testing
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market Open
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)
 
The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196
 
How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...
 
Ajax World Comet Talk
Ajax World Comet TalkAjax World Comet Talk
Ajax World Comet Talk
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!
 
Back To The Future.Key 2
Back To The Future.Key 2Back To The Future.Key 2
Back To The Future.Key 2
 

Dernier

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
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 WorkerThousandEyes
 
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 educationjfdjdjcjdnsjd
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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.pdfsudhanshuwaghmare1
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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 DiscoveryTrustArc
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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...DianaGray10
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 

Drools Fisl

  • 1. Fernando Meyer fmeyer@codehaus.org www.jboss.org www.fmeyer.org
  • 4. History of Rule Engines 70s: Mycin/E-Mycin 80s: CLIPS + many more (expert systems)‫‏‬ 90s: BRMS (Ilog, Fair Isaac)‫‏‬ (business rules management)‫‏‬
  • 5. Practical rule engines Humorous introduction Thanks to Thomas Meeks (it tries to be funny)‫‏‬
  • 6. What are rule engines for? Add rules == expert system (a system that emulates a domain expert)‫‏‬ BRMS == Business Rule Management System (central management of changing business rules)‫‏‬ Decision services (automated decisions, decision support)‫‏‬
  • 7. No really? What are they good for? Some example users: HR (coping with multiple awards)‫‏‬ Transport (monitoring sensors)‫‏‬ Mortgage products (> 4000 rules)‫‏‬
  • 8. Drools is an engine++ IDE (developer tooling) – debugging Web based tooling (analysis – BRMS)‫‏‬ Deployment tools CEP/Stream processing (future)‫‏‬ Testing and analysis tools (next release)‫‏‬ Multiple authoring paradigms: DRL, DSL, XLS (decision tables), PNL, Rule Flow
  • 9. A quick visual tour...
  • 10.
  • 11. IDE
  • 13.
  • 16.
  • 18.
  • 20.
  • 21. Climbing the peak... Helps simplify complicated logic Lowers the cost of changing business logic Usually very fast Basically a business logic framework
  • 23. No silver bullet Rule engines are a complexity, use only as needed, otherwise, grrr.....
  • 24. So, when to use one? Complicated logic (not 1+1 = 3 for large values of 1)‫‏‬ Changes often (whatever that means)‫‏‬ Traditional approaches are a challenge Domain expertise is readily available
  • 25. Don't use for a shopping cart Don't use on applications with simple business logic If the logic is complicated but will never (ever) change, might not need it. Easy logic, changes often? try : Scripting, Lookup tables etc...
  • 27. RETE Latin for “net”. As in network, or graph. Performance is theoretically independent of the number of rules in the system. Hint: its really a stateful optimisation technique, no-one expects you to know it (or care).
  • 28.
  • 29. Example Lets use rules to solve a real world scenario Well, real, perhaps if you are a pirate
  • 30.
  • 31.
  • 32. A Domain expert Yarr, Launch every ZIG ! (Captn' Domain Expert)‫‏‬
  • 33. if (us.somebodySetUsUpTheBomb()) { for (Zig zig : us.getZigs()) { zig.launch(); // for justice! } }
  • 34. Sally the Mechanic Zigs should not launch without their weapon system...
  • 35. Which of course are... Atomic Kittens
  • 36. if (us.somebodySetUsUpTheBomb()) { for (Zig zig : us.getZigs()) { if (zig.hasAtomicKitty()) { zig.launch(); } } }
  • 37. Johnny the Regulator Zigs must have been inspected in the last 24 hours to launch!
  • 38. if (us.somebodySetUsUpTheBomb()) { for (Zig zig : us.getZigs()) { if (zig.hasAtomicKitty()‫‏‬ && zig.isInspected()) { zig.launch(); } } }
  • 39. Johnny the Regulator Oh, and rule 23.43-57a#32.57 explicitly states that no more than 10 Zigs can fly at a time!
  • 40. if (us.somebodySetUsUpTheBomb()) { int i = 0; for (Zig zig : us.getZigs()) { if (i == 10) { break; } if (zig.hasAtomicKitty()‫‏‬ && zig.inspected()) { zig.launch(); i++; } } }
  • 41. Capt'n Domain expert Arr! Only 10!? If a Zig be shot down, launch more!
  • 42. Hmmm... We could keep checking every Zig's status in an infinite loop. We could implement the observer pattern on Zigs (when they explode, they tell someone). etc... <snore> Lets stick with the loop for the example
  • 43. int i = 0; while (us.somebodySetUsUpTheBomb()) { for (Zig zig : us.getZigs()) { if (zig.hasExploded()) { us.getZigs().remove(zig); i--; continue; } if (zig.hasAtomicKitty() && zig.inspected()‫‏‬ && i < 10) { zig.launch(); i++; } } }
  • 44. Sally the Mechanic If those Zigs get beat up, they should land so I can fix them! And don't try to launch them while I'm working on them!
  • 45. int i = 0; while (somebodySetUsUpTheBomb()) { for (Zig zig : us.getZigs()) { if (zig.needsMaintenance()) { zig.land(); mechanic.startFixing(zig); i--; continue; } if (zig.hasExploded()) { us.getZigs().remove(zig); i--; continue; } if (zig.hasAtomicKitty() && zig.inspected()‫‏‬ && i < 10 && !zig.inMaintenance()) { zig.launch(); i++; } } } Hint: Most likely “inMaintenance” check will be forgotten, the first time....
  • 46. Johnny the Regulator I forgot to mention that rule 23.43-57a#32.57a explicitly states that all Zigs can fly if you fax form 453.438-347#B in triplicate
  • 47. Capt'n Domain expert Arr! That form takes hours to fill! Arr! Launch 10 until we fax it, then Take off every Zig!
  • 48. int i = 0; while (somebodySetUsUpTheBomb()) { form.asyncFillOutAndFax(); for (Zig zig : us.getZigs()) { if (zig.needsMaintenance()) { zig.land(); mechanic.startFixing(zig); i--; continue; } if (zig.hasExploded()) { us.getZigs().remove(zig); i--; continue; } if (zig.hasAtomicKitty() && zig.inspected()‫‏‬ && (i < 10 || form.isFaxed()) && !zig.inMaintenance()) { zig.launch(); i++; } } }
  • 49. Johnny the Regulator We just changed the rules! All Zigs must be pink to fly
  • 50. Sally the Mechanic Paint them pink!? That will take months! We have thousands!
  • 51. Capt'n Domain expert Arr! Take off all pink Zigs! If we finish painting a Zig, launch it!
  • 52. Getting complicated? Thousands of Zigs? That loop could take a while A lot of event-driven logic Looks like it is going to end up really messy No, the regulator will not stop
  • 53. Wait a second... You might be thinking – that was awfully arbitrary! Or – Hey, I can make up stupid requirements that are hard to implement in a huge loop cleanly too! I must assume you aren't in a regulated industry...
  • 55. rule “take off every zig (for great justice)” no-loop true; when Us(somebodySetUpUsTheBomb == true)‫‏‬ zig : Zig(inspected == true, pink == true, atomicKitten == true, inMaintenance == false, launched == false)‫‏‬ launched : launched(launched < 10 || formFaxed == true)‫‏‬ then zig.launch()‫‏‬ launched.increment()‫‏‬ update(zig)‫‏‬ update(launched)‫‏‬ end
  • 56. rule “zig explodes” no-loop true when zig : Zig(destroyed == true)‫‏‬ launched : Launched()‫‏‬ then retract(zig)‫‏‬ launched.decrement()‫‏‬ update(launched)‫‏‬ end
  • 57. rule “repair zig” no-loop true when zig : Zig(needsMaintenance == true)‫‏‬ mechanic : Mechanic()‫‏‬ launched : Launched()‫‏‬ then zig.land(); launched.decrement(); mechanic.startFixing(zig); //update zig when done update(zig); end
  • 58. Where is the loop? Implied Each rule fires for each fact combination that matches If you “assert” (insert) 1000 Zigs, the first rule will be checked 1000 times (but it remembers, indexes, for future data changes)‫‏‬
  • 59. What else is good New rules can be gracefully inserted into a large ruleset (even while running)‫‏‬ Will automatically fire when conditions are met Caching facts makes execution very fast Properly managed rules can create very dynamic systems
  • 60. The trough of disillusionment Easy to overuse rules Not all logic (even in complex systems) should be in rules Notice that there is no rule describing how a Zig launches Bugs in overly complex rules can be evil
  • 62. C Bug
  • 64. A quick aside on choosing a rule engine.. It needs to have a NOT conditional (e.g. Operate on the non-existence of a fact)‫‏‬ Don't trust claims of graphical programming It is neat, but not a silver bullet Ditto for “end user computing” Be realistic
  • 65. Deployment models Decision service -Typically a web service (centrally hosted)‫‏‬ Embedded into an application Central BRMS server
  • 66. Some standards Java API: JSR94 * SBVR (OMG) RuleML RIF (W3C) *
  • 67. Other products Ilog JRules Fair Isaac Blaze Advisor Corticon -interesting spreadsheet based rule modelling RuleBurst (now Haley)‫‏‬ -specialise in natural language and rules extracted from documentation
  • 68. Roadmap for 2008 CEP Testing & Analysis (Automated QA)‫‏‬ Integrated processes (BPM)‫‏‬ “process server” (decision services)‫‏‬
  • 69. Thanks ! fernando.meyer@redhat.com www.jboss.org Read the blog: blog.athico.com Me: www.fmeyer.org Thanks Michael

Notes de l'éditeur