jboss brms - the enterprise platform for business logic

45
Agenda JBoss BRMS overview JBoss BRMS benefits JBoss BRMS and Guvnor JBoss BRMS Assets package facts working sets rules decision tables test scenarios event process processing (CEP) other assets JBPM5 processes JBoss BRMS authoring JBoss BRMS deployment Eclipse integration Rule agents

Upload: jbug-italy

Post on 29-Jan-2018

4.327 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: JBoss BRMS - The enterprise platform for business logic

Agenda

JBoss BRMS overviewJBoss BRMS benefits

JBoss BRMS and Guvnor

JBoss BRMS Assetspackagefactsworking setsrulesdecision tablestest scenariosevent process processing (CEP)other assets

JBPM5 processes

JBoss BRMS authoring

JBoss BRMS deployment

Eclipse integration

Rule agents

Page 2: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS:

The enterprise platform for

Business Logic Integration

Giovanni Marigi

gmarigi at redhat.com

JBoss ConsultantRed Hat, Inc.Codemotion 2012

Except where otherwise noted, content on this work is licensed under a Creative Commons Attribution 3.0 License.

Page 3: JBoss BRMS - The enterprise platform for business logic

Agenda

JBoss BRMS overviewJBoss BRMS benefits

JBoss BRMS and Guvnor

JBoss BRMS Assetspackagefactsworking setsrulesdecision tablestest scenariosevent process processing (CEP)other assets

JBPM5 processes

JBoss BRMS authoring

JBoss BRMS deployment

Eclipse integration

Rule agents

Page 4: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Overview

BRMSBRMS (business rules management system)a software where to define and externalize the business and decision logic used inside programs inside an organization

Page 5: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Overview

Page 6: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Overview

BRMSBRMSa single platform for business modeling including different technologies

JBoss BRMS includes:ExpertExpert: Rule EngineFlow/JBPM5Flow/JBPM5 : Rules Process ManagementFusionFusion: Complex Event ProcessingGuvnorGuvnor: BRMS “front end” and repository for BRMS artifacts

JBoss BRMS is distributed:. war archive. already packaged with an EAP/EWP. ready for AS7

Page 7: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS overview: main features

Centralized repository of business assets

Version control of business assets

IDE/User tools to define and to “governance” the decision logic

Build, deploy, testing of decision logic

Packages of business assets

Categorization of business assets

Roundtrip, integration with dev Tools (Eclipse)

JCR repository (jackrabbit or modeshape) for assets

Repository can also be accessed via REST API - HTTP (WebClient) - WebDAV

BRMS can be configured for high availabilty (clustering)

Page 8: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS overview: benefits

Logic and data separation

Cross domain logic

Reuse, logic opened to changes

Easy to maintain the business logic

Changes in live systems

Several stakeholders can contribute in defining the business logic (Business Analyst, Rule expert, Developer, Administrators)

Page 9: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS and Guvnor

Drools Guvnor 5.4.0 Beta1

Drools Guvnor 5.3.0 last stable

Drools Guvnor 5.3.0 includes: Expert 5.3 (rule engine)Fusion 5.3 (CEP)Flow/JBPM5

Eclipse + JBoss Tools

BRMS 5.2 last stable

BRMS 5.2 includes:- Drools Guvnor 5.2- Drools Expert 5.2- Drools Fusion 5.2

BRMS 5.3 (next release) will be based on Guvnor 5.3

JBoss Developer Studio

Bug fixing,patchingSLAEnterprise certification | QA

Page 10: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS and Guvnor

Feature Community Enterprise

Open Source x x

Benefits from testing by worldwide Community x x

Recommended for Production Use x

Patch Update & Service Pack Program x

Security Errata Program x

Automated Software Update & Alert Service x

Defect & Feature Escalation & Prioritization Process x

Developer Support x

24x7 Production Support & Services x

Platform Certifications & Training Certifications x

Defined Support SLA and End-of-Life Policy x

Out-of-the-Box Configured for Enterprise Use x

Operations Management Tools x

Platform testing & certification process x

Redistribution of modified JBoss technologies x

Red Hat Open Source Assurance (Legal Protection) x

Page 11: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets

Every artifact inside a BRMS is an assetasset

The assets define a knowledge baseknowledge base

Business logic is made by several assets:facts (domain model)rules business processes (workflows)decision tablesfunctionsmore...

Not only business rules!

Page 12: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Package

Guvnor Knowledge base

How to start?define a new packagepackage forbusiness assets

Page 13: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Model/Facts

A package must contain at least a fact model

fact model != domain modela fact model typically overlapsoverlaps a domain model but better to make it decouple from the domain model

Rules and assets reason upon a fact model

Two ways to do define your fact model:- upload a JAR file containing Java Classes - declare a model within Guvnor

Page 14: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Working Sets

Working sets are groups of facts

Use them to put constraints on a group of facts and restrict the “reasoning domain” of your business rules

Disabled by default

Page 15: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Rules

Rules are the “backbone” of a BRMS

Don't use a BRMS if you don't have business rules

Don't use a BRMS if you don't want or you can't separate logic from data

Rules are processed and evaluated by a Rule Engine (Drools Expert)

Forward chaining rule engine which implements the RETE algorithm (ReteOO)

Rich native language to define rules

A rule is contained in a DRL file

More info on Drools Expert:JBug Italy slideshare site:http://www.slideshare.net/jbugrome

Page 16: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Rules

Forward chaining

Rule Engine

Page 17: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Rules

rule "Approve if not rejected" salience -100 agenda-group "approval" when not Rejection() p : Policy(approved == false,policyState:status ) exists Driver(age > 25) Process(status == policyState) then log("APPROVED: due to no objections."); p.setApproved(true);end

Anatomy of a rule

Example of a rule

Page 18: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Rules

Inside BRMS there 4 ways to createa rule:

- from scratch,code; (requires knowledge of Expert)

- using the guided editor(can be used DSL assertions)

- uploading a decision tablespreadsheet

- creating a decision table spreadsheet via the guided editor

Page 19: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Rules

Rules can be validated inside BRMS

Page 20: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Rules

Rules with the guided editor

Page 21: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Decision Tables

Express rules with a spreadsheet

A spreadsheet can be imported or created via the guided web editor

A wizard generator for spreadsheet is available in BRMS!

A decision table at runtime is transformed in a series of DRL rules

Page 22: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Test Scenarios

Test scenarios are assets used to validate that the rules inside the knowledge base (package) works as expected

A scenario is made by a given section (list of facts and its initial state) and an expect section

What we can “assert” in a expect section?

- RuleValidate that a certain rule fired.

- Fact valueValidate fact values for a fact created in the Given section.

-Any fact that matchesValidate that there is at least one fact in the knowledge base with the specified field values.

Page 23: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: Test Scenarios

Page 24: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: CEP

CEP Engine enables Event Detection: Cloud mode and Stream mode

Temporal Reasoning (correlation) – reason over aggregation

Abstraction – Compose complex events and reason over them

CEP Engine SupportsEvent Semantics (point in time and interval) as first

class citizen analogous to rule semantics

Support both point in time (as interval with zero duration) and interval semantics

Ability to apply temporal constraints

Use Session clocks: Support Realtime (system) clock, Psedo Clock (controlled by application)

Sliding window support

Ability to scale to high volume of events

Page 25: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: CEP

Event A before Event B

Event A meets Event B

Event A overlaps Event B

Event A finishes Event B

Event A includes Event B

Event A starts Event B

Event A coincidces Event B

Event A after Event B

Event A metBy Event B

Event A overlapedBy Event B

Event A finishedBy Event B

Event A during Event B

Event A finishes Event B

when

Shipment( $pickupTime : scheduledPickupTime )

not ShipmentPickup( this before $pickupTime )

then

// shipment not picked up... Action required.

end

rule “Shipment not picked up in time”

13 Operators are Supported

Page 26: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: CEP

Apply 13 operators available

Define sliding time window or length

Page 27: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS other assets

Spring contexteditor to define spring context files;once created they are accessible via HTTP inside the package

DSL functionsDefine rules in a domain specific language

EnumerationEnum data to be used in rules

Functions

Rule templates

Page 28: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS other assets

A guided rule with DSL assertions

Page 29: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: JBPM5

A workflow is a process that describes the order in which a series of steps need to be executed, using a flow chart.

JBPM5 is based on Drools Flow

Workflow guided by rules

Rule workflows are the new “generation” of business workflows

Rules + workflow: dynamic processes

Available in BRMS 5.3

Page 30: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: JBPM5

JBPM5 workflow are BPMN2BPMN2 processes

No legacy xml to define the workflow but a standard!

Human task (human interaction with a flow)The task service implementation is based on the WS-HumanTask (WS-HT) specification

Rule Task: use drools rules inside the flow

Pluggable Service Task (work items): nodes with custom logic (e.g. DBControl, EJBControl, EmailControl)

Gateway (split,converge)the decision in a gateway can be taken by a drools rule!

Events (start,end,intermediate)

Timers

Page 31: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: JBPM5

BPMN2 editor in Eclipse

BPMN2 editor in BRMS (web designer)

BRMS can upload BPMN2 processes designed with other BPMN2 modeling tool

Automatic creation of human task forms

Validation of BPMN2 processes

Online repository to download ready to use service tasksJBPM Service repository

JBPM 3 to 5 migration toolhttps://github.com/droolsjbpm/jbpmmigration

Page 32: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: JBPM5

When defined a new work item is available inside Eclipse

Page 33: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS assets: JBPM5

Web Designer integrated inside BRMS (starting from BRMS 5.3)

Page 34: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS authoring

Every asset in BRMS is versioned; every time an asset changesa new version number is attached

Assets anyway can't be branched or tagged!

An asset contains meta data information

Assets can be categorized

An asset can be linked to many categories

Categories don't have any meaningat runtime; useful to order the assets

An asset can have a status (e.g “Draft”, “Completed”); it's a sort of label

Page 35: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS authoring

A package otherwise is versioned on demand, taking a snapshot for deployment

Creating a snapshot means that the BRMS package is ready to be used from external application

Before taking a snapshot a build package is required

With a build every assets inside the package is validated

Status and Categories can be used to select only specific assets to include inside a snapshot (Use selector)(e.g. create a snaposhot only with assets belonging to category “Fraud” and with Status “Completed”)

A snapshot will be published inside the repository and accessible via a URL

Page 36: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS authoring

Page 37: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS deployment

Page 38: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS deployment

Stand Alone Package

Well integrated

Best Out of the Box Experience

Lightweight Package

Flexibility of Container

Deploy to lightweight containers like Tomcat

Page 39: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Eclipse integration

Eclipse can be configured to import the resources (assets) published in BRMS

Assets can be edited in Eclipse and committed to BRMS (complete roundtrip)

Eclipse gives the capability to compare different version of the same asset

Requires JBoss Developer Studio 4.x or Eclipse 3.6.x + JBoss Tools

File --> Import --> Guvnor --> Resources from Guvnor

Page 40: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Eclipse integration

Page 41: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Rule Agent

How to use a BRMS package inside your application?

Create a Drools RuleAgent able to get (download) its KnowledgeBase from BRMS

Define a change-set.xml (simple xml file) file where the BRMS packages are listed

The KnowledgeBase is the entry point to fire rules, execute bpmn processes,...

Page 42: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Rule Agent

KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("MyAgent", kaconf);

kagent.applyChangeSet(ResourceFactory.newClassPathResource("change-set.xml"));KnowledgeBase

kbase = kagent.getKnowledgeBase();

change.set.xml

<?xml version="1.0" encoding="UTF-8"?><change-set xmlns="http://drools.org/drools-5.0/change-set"xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"xs:schemaLocation="http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd" >

<add>

<resource source="http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/JBUG/LATEST" type="PKG" basicAuthentication="enabled" username="uid" password="pwd"/>

</add>

</change-set>

Page 43: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS Rule Agent

final StatefulKnowledgeSession ksession = kagent.getKnowledgeBase();

//insert fact instances in kbksession.insert(new Car("AudiA4",4)); ksession.startProcess("Process1");ksession.fireAllRules();ksession.dispose()

What to do with a KnowledgeBase?

start a process and insert some fact instances to be evaluated inside a process RuleTask

Page 44: JBoss BRMS - The enterprise platform for business logic

Resources

http://www.jboss.org/drools/lists

http://www.jboss.org/jbpm/lists

IRC server: irc.codehaus.org

Channels: #drools #guvnor #jbpm

THAT'S ALL FOLKS!THAT'S ALL FOLKS!

Page 45: JBoss BRMS - The enterprise platform for business logic

JBoss BRMS:

The enterprise platform for

Business Logic Integration

THANKS!gmarigi at redhat.com

Except where otherwise noted, content on this work is licensed under a Creative Commons Attribution 3.0 License.