Download - All the cool stuff of JBoss BRMS
All the cool stuff of JBoss BRMS
Giovanni MarigiJBoss ConsultantRed Hat, Inc.January 2012
String.class.getName()
Agenda
What is a BRMS?
BRMS features
BRMS benefits
BRMS - Guvnor
BRMS Assets
package
facts
working sets
rules
decision tables
test scenarios
other assets
JBPM5 processes
BRMS authoring
Eclipse integration
Rule agents
What is a BRMS?
BRMS (business rules management system)
a software where to define and externalize the business and
decision logic used inside programs inside an organization
What is a BRMS?
BRMS
a single platform for business modeling
JBoss BRMS includes:
Expert: Rule Engine
Flow/JBPM5 : Rules Process Management
Fusion: Complex Event Processing
Guvnor: BRMS front end and repository for BRMS artifacts
JBoss BRMS is distributed:
. war archive
. already packaged with an EAP
. ready for AS7
What is a BRMS?
Every artifact inside a BRMS is an asset
The assets define a knowledge base
Business logic is made by several assets:
facts (domain model)
rules (of course)
business processes (workflows)
decision tables
functions
more...
Not only business rules!
BRMS 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
BRMS can be configured for high availabilty
BRMS 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)
BRMS - 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,patching
SLA
Enterprise certification | QA
BRMS assets - Package
Guvnor Knowledge base
How to start?
define a new package for
business assets
BRMS assets: Model/Facts
A package must contain a fact model
fact model != domain model
a fact model typically overlaps 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
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
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
BRMS assets: Rules
Forward chaining
Rule Engine
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
BRMS assets: Rules
Inside BRMS there 4 ways to create
a rule:
- from scratch,code;
can be validated inside BRMS
(requires knowledge of Expert)
- using the guided editor
- uploading a decision table
spreadsheet
- creating a decision table
spreadsheet via the guided editor
BRMS assets: Rules
Validation of a rule written from scratch
BRMS assets: Rules
Rules with the guided editor
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
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?
- Rule
Validate that a certain rule fired.
- Fact value
Validate fact values for a fact created in the Given section.
-Any fact that matches
Validate that there is at least one fact in the knowledge base with
the specified field values.
BRMS assets: Test Scenarios
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 workflow is the new generation of business workflow
Rules + workflow: dynamic processes
BRMS assets: JBPM5
JBPM5 workflow are BPMN2 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 agateway can be taken by a drools rule!
Events (start,end,intermediate)
Timers
BRMS assets: JBPM5
BPMN2 editor in Eclipse
BPMN2 editor in BRMS (web editor)
BRMS can upload BPMN2 processes designed with other BPMN2 modeling tool
Online repository to download ready to use service tasks
JBPM Service repository
JBPM 3 to 5 migration tool
https://github.com/droolsjbpm/jbpmmigration
BRMS assets: JBPM5
When defined a new work item
is available inside Eclipse
BRMS assets: JBPM5
Web Editor integrated inside BRMS (starting from BRMS 5.3)
Available in Guvnor 5.3
BRMS other assets
Spring context
editor to define spring context files;once created they are
accessible via HTTP inside the package
DSL functions
Define rules in a domain specific language
Enumeration
Enum data to be used in rules
Functions
Rule templates
BRMS authoring
Every asset in BRMS is versioned; every time an asset
changes
a 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 meaning
at runtime; useful to order the assets
An asset can have a status
(e.g Draft, Completed);
it's a sort of label
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
BRMS authoring
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
BRMS Eclipse integration
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,...
BRMS Rule Agent
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("MyAgent", kaconf);
kagent.applyChangeSet(
ResourceFactory.newClassPathResource("change-set.xml"));KnowledgeBase
kbase = kagent.getKnowledgeBase();
change.set.xml
BRMS Rule Agent
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();//insert fact instances in kbksession.insert(new Car("AudiA4",4)); ksession.startProcess("Process1");ksession.fireAllRules();ksession.dispose()
What to do with a KnowledgeBase?
For example start a process and insert some fact instances to be
evaluated inside a process RuleTask
BRMS Access BRMS repo
BRMS repository can also be accessed
- REST API
- HTTP (WebClient)
- WebDAV
BRMS Resources
http://www.jboss.org/drools/lists
http://www.jboss.org/jbpm/lists
IRC server: irc.codehaus.orgChannels: #drools #guvnor
#jbpm
THAT'S ALL FOLKS!
All the cool stuff of JBoss BRMSTHANKS!
Click to edit the title text format
Click to edit the outline text format
Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level