Top Banner
1 JBoss Enterprise BRMS The Road to Large Scale Enterprise Solutions Phil Simpson, Product Marketing Manager Eric Schabell, JBoss Technology Evangelist
37

Best practices webinar

Jan 13, 2015

Download

Documents

Your enterprise can become truly intelligent
-------------------------------------------
Get there with Red Hat’s JBoss® Enterprise Business Rules Management System (BRMS), a key component of our vision for the intelligent, integrated enterprise. It delivers the power of business rules, complex event processing, and business process management in a single open source distribution—all accessible from a common set of authoring tools.

JBoss Enterprise BRMS supports a broad range of decision-management and process-driven applications with a unique combination of open source technologies:

- jBPM5 business process management
- Drools business rules
- Drools Fusion complex event processing

Build rule, event, and process-driven applications that scale across the enterprise
-------------------------------------------
Discover best practices for constructing BRMS applications that support large numbers of rules operating on big data. We’ll illustrate common use cases with real-world case studies and give you practical tips for estimating computing resource requirements.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Best practices webinar

1

JBoss Enterprise BRMSThe Road to Large Scale Enterprise Solutions

Phil Simpson, Product Marketing Manager

Eric Schabell, JBoss Technology Evangelist

Page 2: Best practices webinar

2

JBoss BRMS Overview

Page 3: Best practices webinar

3

JBoss Enterprise BRMS

Web-based development tools

Business Analysts

Developers

JBDS, with BRMS plugins

Business ProcessManager

Rule Engine

Event Processor

Enterprise Application

Web Service

Java Code

Business Users

Business Process

Definitions

Repository

Business Rule & Event

Definitions

Business Events

Business Data

Deploy

Interacts with...

Management Console

Operations

Manage & M

onitor

DecisionService

Page 4: Best practices webinar

4

JBoss Enterprise BRMS

Web-based development tools

Business Analysts

Developers

JBDS, with BRMS plugins

Business ProcessManager

Rule Engine

Event Processor

Enterprise Application

Web Service

Java Code

Business Users

Business Process

Definitions

Repository

Business Rule & Event

Definitions

Business Events

Business Data

Deploy

Interacts with...

Management Console

Operations

Manage & M

onitor

DecisionService

Page 5: Best practices webinar

5

JBoss Enterprise BRMS

Web-based development tools

Business Analysts

Developers

JBDS, with BRMS plugins

Business ProcessManager

Rule Engine

Event Processor

Enterprise Application

Web Service

Java Code

Business Users

Business Process

Definitions

Repository

Business Rule & Event

Definitions

Business Events

Business Data

Deploy

Interacts with...

Management Console

Operations

Manage & M

onitor

DecisionService

Page 6: Best practices webinar

6

JBoss Enterprise BRMS

Web-based development tools

(Guvnor)

Business Analysts

Developers

JBDS, with BRMS plugins

Business ProcessManager

Rule Engine

Event Processor

Enterprise Application

Web Service

Java Code

Business Users

Business Process

Definitions

Repository

Business Rule & Event

Definitions

Business Events

Business Data

Deploy

Interacts with...

Management Console

Operations

Manage & M

onitor

DecisionService

Page 7: Best practices webinar

7

JBoss Enterprise BRMS

Web-based development tools

Business Analysts

Developers

JBDS, with BRMS plugins

Business ProcessManager

Rule Engine

Event Processor

Enterprise Application

Web Service

Java Code

Business Users

Business Process

Definitions

Repository

Business Rule & Event

Definitions

Business Events

Business Data

Deploy

Interacts with...

Management Console

Operations

Manage & M

onitor

DecisionService

Page 8: Best practices webinar

8

Best PracticesDeveloping BRMS Applications that Scale

● BRMS Adoption Goals● Under the Hood● Best Practices

● BPM ● Architecture● Rules Authoring

Page 9: Best practices webinar

9

BRMS adoption goals

Page 10: Best practices webinar

10

Goal #1: Decision Automation

Adapted from a presentation by James Taylor, Sep/2011

Time

Bus

ines

s V

alue

Business EventBusiness Event

ReactionReaction

Val

ue L

oss

Time Loss

Conclusion: Time is Money!

Page 11: Best practices webinar

11

Goal #2: Expressiveness and Visibility

rule “Send shipment pick-up SMS alert”

when

There is a shipment order

There is a route assigned to the order

There is a truck GPS reading and the truck is 15 minutes

away from the pick-up location

then

Send SMS to customer: “Arriving in 15 minutes”

end

rule “Send shipment pick-up SMS alert”

when

There is a shipment order

There is a route assigned to the order

There is a truck GPS reading and the truck is 15 minutes

away from the pick-up location

then

Send SMS to customer: “Arriving in 15 minutes”

end

Focus on “what to do” instead of “how to do it”

Page 12: Best practices webinar

12

Goal #3: Performance and Scalability

● Real time, online, systems● Millisecond response times

● Hundreds of thousands of rules● JBoss BRMS: 700k+ rules

● Millions of data instances (facts)

● Incremental (re-)evaluation● Changes in data can't reset reasoning

Page 13: Best practices webinar

13

Goal #4..#6: other technical goals

● Logic, Data and Tasks split

● Centralization of Knowledge

● Consistency● Testing / Simulation● Auditing

● Explanation Facility

Knowledge Base

(rules/events/processes)

Knowledge Session

(data)InferenceEngine

Tasks

Page 14: Best practices webinar

14

JBoss BRMS: under the hood

Page 15: Best practices webinar

15

Engine's Algorithm – 30 seconds crash course

Customer Order Total Amount

Discount

Gold 15%

Silver < $1000 5%

Silver >= $1000 10%

Decision Table: User's View

Data

Customer Order

Gold Silver < $1000 >=$1000

Discount: 15% Discount: 5% Discount: 10%

Rete Network: Computer's View

Clear, Concise, Objective

Efficient, Effective

Page 16: Best practices webinar

16

JBoss BRMS – some optimizations

● Support to POJOs as facts ● no mapping/data copy necessary

● Full split between Knowledge Base and Session● lightweight session creation● knowledge base sharing

● Completely Dynamic Knowledge Base● Hot addition/removal/updates of rules/queries/processes

● Full support to First Order Logic and Set operations

● JIT compilation for constraints and data access

Page 17: Best practices webinar

17

JBoss BRMS – More optimizations

Data

Customer Order

Gold Silver < $1000 >=$1000

Discount: 15% Discount: 5% Discount: 10%

Alpha Hashing

Node Sharing

Data Indexing

Lazy Matching

Page 18: Best practices webinar

18

JBoss Enterprise BRMS

Page 19: Best practices webinar

19

Best Practices – BPM Architecture

Process Repository

BPMN2 Authoring for Business Users

BPMN2 Authoring for Developers

Human TasksWeb Services

Interaction Layer

JBPM ConsoleReporting,

BAM Dashboards

Process Implementation Layer

Process Initialization

Layer

EJB / POJO ESB

Queues

Customer

Developer

Page 20: Best practices webinar

20

Best Practices – Process Initialization

● How do you start your process?● web services, EJB's, API call, RESTful● what about prioritization of processes

● use message queues● other complex ideas to start processes

● Centralize startProcess in single location● minimizes change effects in this layer

Queues

Process Initialization

Layer

EJB MDB

Customer

Page 21: Best practices webinar

21

Best Practices – Process Implementation

● Java nodes● do you keep it clean?

● single unit of action per process step● human task / admin interfaces

● Centralize you jBPM API access ● single WS / DAO / BOM / RESTful

● Domain specific nodes● extensions via work item handlers

● Design process for reuse● smallest unit of work

Process Implementation Layer

Page 22: Best practices webinar

22

Best Practices – Process Interaction

● Processes interact with your Enterprise● Web Services, EJB, GUI, POJO, Exceptions, Bean

Script, Rules...● jBPM API & jBPM History DB & RESTful● history / tasks / reporting

● single DAO● single Web Service● JBoss ESB + jBPM● externalize rules calls in Decision Service (WS)

Human TasksWeb Services

Interaction Layer

EJB / POJO ESB

Page 23: Best practices webinar

23

Best Practices – Always good BPM practices...

● Simplify everything (KISS)● apply OO to process design

● methods == sub-process + context in/out● encapsulate == sub-process● reuse == process repo (maven potential)● unit testing == per node, sub-process, process● exception handling (Exception Framework)

Page 24: Best practices webinar

24

Best Practices – Rule Architecture

● Partition your Knowledge Bases properly

● Subject matter● Transaction / Service / Unit of Work● Business Entity

● Avoid monolithic Knowledge Bases

● Avoid fine grained Knowledge Bases

Knowledge Base

Knowledge Session

InferenceEngine

Tasks

Page 25: Best practices webinar

25

Best Practices – Rule Architecture

● Batch data loads

● Load 1000 facts and fire the rules faster than fire rules after each loaded fact

● Partition the data into multiple sessions

● Transaction / Service / Unit of work● Creating a new session is cheap

● Cheaper than removing facts Knowledge

BaseKnowledge

SessionInferenceEngine

Tasks

Page 26: Best practices webinar

26

Best Practices – Rule Architecture

● Quality of the data/fact model is directly proportional to the performance and maintainability of the rules using it

● Think about the DBMS analogy● Flatter models improve performance● Smaller classes help avoiding recursions

Knowledge Base

Knowledge Session

InferenceEngine

Tasks

Page 27: Best practices webinar

27

JBoss BRMS – Best Practices in Rules Authoring

Page 28: Best practices webinar

28

Best Practices – Rules Authoring

● Don't try to micro-control rules execution

● Use the Conflict Resolution Strategies instead● Salience● Agenda groups● Ruleflow / Processes● Dynamic Enablement

Knowledge Base

Knowledge Session

InferenceEngine

Tasks

Page 29: Best practices webinar

29

Best Practices – Rules Authoring

● Don't overload rules

● Each rule should describe one and only one scenario→action mapping

● The engine will optimize shared conditions● The engine supports inference

Knowledge Base

Knowledge Session

InferenceEngine

Tasks

Page 30: Best practices webinar

30

Best Bad Practices – Rules Authoring

rule “1 – Teenagers and Elders get Discount”

when

Person age is between 16 and 18 or Person age is greater or equal to 65

then

Assign 25% ticket discount

end

rule “1 – Teenagers and Elders get Discount”

when

Person age is between 16 and 18 or Person age is greater or equal to 65

then

Assign 25% ticket discount

end

rule “2 – Elders can buy tickets in area A”

when

Person age is greater or equal to 65

then

Allow sales of area A tickets

end

rule “2 – Elders can buy tickets in area A”

when

Person age is greater or equal to 65

then

Allow sales of area A tickets

end

Rules are being overloaded with multiple concepts, increasing maintenanceand testing costs.

Page 31: Best practices webinar

31

Best Practices – Rules Authoring

rule “0.a – Teenagers are 16-18”

when

Person age is between 16 and 18

then

Assert: the person is a Teenager

end

rule “0.a – Teenagers are 16-18”

when

Person age is between 16 and 18

then

Assert: the person is a Teenager

end

rule “0.b – Elders are older than 65”

when

Person is older than 65

then

Assert: the person is an Elder

end

rule “0.b – Elders are older than 65”

when

Person is older than 65

then

Assert: the person is an Elder

end

rule “1 – Teenagers and Elders get discount”

when

Teenager or Elder

then

Assign 25% ticket discount

end

rule “1 – Teenagers and Elders get discount”

when

Teenager or Elder

then

Assign 25% ticket discount

end

rule “2 – Elders can buy tickets in area A”

when

Elder

then

Allow sales of area A tickets

end

rule “2 – Elders can buy tickets in area A”

when

Elder

then

Allow sales of area A tickets

end

Page 32: Best practices webinar

32

Best Practices – Rules Authoring

● One calculation (accumulate) per rule

● Accumulates have O(n) performance

● Sequences of accumulates have O(nm) performance

● n = number of matching facts● m = number of accumulates

rule “Sum debits and credits”

when

accumulate( Debit( $d : amount ),

$debits: sum( $d ) )

accumulate( Credit( $c : amount),

$credits: sum( $c ) )

then ...

rule “Sum debits and credits”

when

accumulate( Debit( $d : amount ),

$debits: sum( $d ) )

accumulate( Credit( $c : amount),

$credits: sum( $c ) )

then ...

rule “Sum debits”

when

accumulate( Debit( $d : amount ),

$debits: sum( $d ) )

then ...

rule “Sum debits”

when

accumulate( Debit( $d : amount ),

$debits: sum( $d ) )

then ...

rule “Sum credits”

when

accumulate( Credit( $c : amount ),

$credits: sum( $c ) )

then ...

rule “Sum credits”

when

accumulate( Credit( $c : amount ),

$credits: sum( $c ) )

then ...

Page 33: Best practices webinar

33

Best Practices – Rules Authoring

● Rules vs Queries

Rules Queries

Control Invoked by the engine Invoked by the application

Parameters Don't support parameters Support parameters

Results Execute actions Return results

rule “Approve VIP customers”

when

$c : Customer( type == “VIP” )

then

insert( new Approved( $c ) );

end

rule “Approve VIP customers”

when

$c : Customer( type == “VIP” )

then

insert( new Approved( $c ) );

end

query “Get customers by type”( $type )

when

$c : Customer( type == $type )

end

query “Get customers by type”( $type )

when

$c : Customer( type == $type )

end

“Use the right tool for the right job!”

Page 34: Best practices webinar

34

Best Practices – Rules Authoring

● Declared Types

● Facts used only by the rules● Facts that change frequently with the rules

● POJOs

● Facts shared by both rules and application● No data copy – very efficient

● Easier to integrate, easier to test● When in doubt, use POJOs

“Use the right tool for the right job!”

Page 35: Best practices webinar

35

Questions?Questions?

Page 36: Best practices webinar

36

Add references

● JBoss Enterprise BRMS Best Practices Guide http://www.redhat.com/promo/integrated_enterprise/brms-best-practices-form.html

● JBoss Enterprise BRMS Best Practices, Edson Tirelli, http://www.redhat.com/summit/sessions/jboss.html

● JBoss BRMS, http://www.redhat.com/products/jbossenterprisemiddleware/business-rules/

● BRMS Best Practices Process Initialization Layer, http://howtojboss.com/2012/08/15/brms-best-practices-process-initialization-layer/

Page 37: Best practices webinar

Thank you!

Find out More: http://www.redhat.com/brms