Drools Workshop @JBCNCONF 2016

20
DROOLS ENABLED MICROSERVICES MAURICIO SALATINO JBCNCONF 2016 - HANDS ON WORKSHOP

Transcript of Drools Workshop @JBCNCONF 2016

DROOLS ENABLED MICROSERVICES

MAURICIO SALATINO

JBCNCONF 2016 - HANDS ON WORKSHOP

DROOLS ENABLED MICROSERVICES

INSTRUCTIONS

▸ Fork: http://github.com/salaboy/drools-game-engine/

▸ Clone your forked repository

▸ git clone http://github.com/<user>/drools-game-engine/

▸ cd drools-game-engine/

▸ mvn clean install -DskipTests

DROOLS ENABLED MICROSERVICES

AGENDA

▸ What is Drools?

▸ Rule Language / Execution Cycle

▸ Drools & Microservices

▸ Scenario

DROOLS ENABLED MICROSERVICES

ABOUT ME

▸ Mauricio Salatino (aka Salaboy)

▸ Work for Red Hat

▸ Drools & jBPM Community

▸ http://salaboy.com

▸ @salaboy

DROOLS ENABLED MICROSERVICES

WHAT IS DROOLS?

▸ Lightweight Rule Engine (a library)

▸ Rule Engine -> Inference Engine

▸ Change of paradigm from Imperative (Java) to Declarative

DROOLS ENABLED MICROSERVICES

RULE STRUCTURE

▸ rule “Warn on low health” //<rule attributes>

When Player( health <= 10 ) Then // Warning.. find medicine end

DROOLS ENABLED MICROSERVICES

DROOLS ENGINE OVERVIEW (STATIC)

DROOLS ENABLED MICROSERVICES

DROOLS ENGINE OVERVIEW (RUNTIME)

DROOLS ENABLED MICROSERVICES

RULE EXECUTION CYCLE

DROOLS ENABLED MICROSERVICES

KIE APIS

▸ KieContainer

▸ KieBase

▸ KieSession

▸ insert(Object)

▸ retract(FactHandle)

▸ update(FactHandle, Object)

▸ fireAllRules() / fireAllRules(int)

▸ KieScanner

▸ kmodule.xml

DROOLS SPECIFICS

DROOLS ENABLED MICROSERVICES

MICROSERVICES KEY POINTS

▸ Bounded Context - Domain Driven Design

▸ Aligned with the company structure

▸ Small, managed by a team that knows about that department requirements

▸ Using the right tool for the job ;)

▸ Release Fast - Release Early - Iterate

DROOLS ENABLED MICROSERVICES

DROOLS ENABLED MICROSERVICES

▸ Separate the business logic from technical aspects

▸ Use the bounded context model, no need to change anything, leverage the scope

▸ Leverage the rule engine features (instead of creating in house solutions to deal with logical checks and tricky scenarios)

▸ More flexible to business changes

▸ Self documented Micro Services

▸ Micro services that provides justification for each decision made out-of the-box

DROOLS ENABLED MICROSERVICES

SCENARIO (GAME)

DROOLS ENABLED MICROSERVICES

SCENARIO (GAME)

DROOLS ENABLED MICROSERVICES

INSTRUCTIONS

▸ Fork: http://github.com/salaboy/drools-game-engine/

▸ Clone your forked repository

▸ git clone http://github.com/<user>/drools-game-engine/

▸ cd drools-game-engine/

▸ mvn clean install -DskipTests

DROOLS ENABLED MICROSERVICES

RULES POWER

▸ Any Java Model (non-intrusive)

▸ Filter Data (Simple Filters)

▸ Correlate Data (Multiple filters between patterns)

▸ Accumulations / Aggregations (accumulate functions)

▸ Inference Chain

▸ Justification Log

▸ Query Data

▸ Truth Maintenance System(TMS)

GETTING STARTED WITH DROOLS

COMMUNITY

▸ www.drools.org / www.jbpm.org

▸ Drools & jBPM Mailing lists

▸ Report Bugs & Suggest Features: jira.jboss.org

▸ irc.freenode.net

▸ #drools

▸ #jbpm

▸ Blogs:

▸ blog.athico.com

▸ salaboy.com

QUESTIONS?

DROOLS ENABLED MICROSERVICES

GETTING STARTED WITH DROOLS

RETE

GETTING STARTED WITH DROOLS

PHREAK