JBPM and Drools Introduction

From Training Material
Revision as of 15:34, 2 November 2017 by Fstachecki (talk | contribs) (→‎Domain Specific Language Rules⌘)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


title
jBPM and Drools Introduction
author

Filip Stachecki (filip@NobleProg.pl), Bernard Szlachta (anbo@nobleprog.com)

jBPM Overview⌘

jBPM General Info ⌘

ClipCapIt-171026-095539.PNG ClipCapIt-171026-095651.PNG
  • jBPM is a BPMS (Business Process Management Suite) written in Java
  • It allows you to design, model, execute, and monitor business processes throughout their life cycle.
  • Contains Drools - Business Rules Management System (BRMS)
  • jBPM, released by JBOSS (Red Hat boght JBOSS)
  • Open Source and Commercial

BPMN ⌘

OMG BPMN.png

  • Business Process Model and Notation (BPMN)
  • OMG standard
  • similar to flowchart diagram, but

Business Process⌘

ClipCapIt-141204-113643.PNG

BPMN 2.0 Spec:

A Process describes a sequence or flow of Activities 
in an organization with the objective of carrying out work.

Howard Smith, Peter Fingar, Business Process Management – The Third Wave, Meghan Kiffer, 2006:

Business Process is the complete and dynamically coordinated set of collaborative 
and transactional activities that deliver value to customers.

Process Logic⌘

by Bruce Silver

ProcessModelManyPaths.png

  • Process Logic (Process Model) is a complete map of all the paths from the triggering event to any defined end state.
  • Process Model is more than documentation of one instance of the process.
  • Process logic is usually hidden.

BPMN 2.0 Purpose ⌘

  • Provide a notation that is readily understandable by business and technical people
  • Create a standardized bridge for the gap between the business process design and process implementation
  • To standardize a business process model and notation
  • To provide a means of communicating process information to other businesses, users, managers and process implementers
  • To exchange BPMN definitions (both domain model and diagram layout) between different tools

Audience of BPMN ⌘

  • Business users
    • Business analysts
    • Strategy analyst
    • Quality managers
  • Technical developers
    • Process designers
    • Developers
    • Integrators
    • Software, System and Enterprise Architects

BPMN Basics⌘

Flow Objects

  • Element start event.png Events (Circles)
  • Element activity.png Activities (Roundtangles)
  • Element gateway.png Gateways (Diamonds)

Swimlanes

  • Element pool.png Pools
  • Element lane.png Lanes

Connecting Objects

  • Element sequence flow.pngSequence Flows
  • Element message flow.pngMessage Flows
  • Element association.pngAssociations
  • Element association.pngData Associations

Artifacts (used to provide additional information about the Process)

  • Element group.png Group
  • Text annotations.png Text Annotation

Levels of BPMN Process Modelling⌘

by Bruce Silver - Three Levels of Process Modeling with BPMN, BPMS Watch, April 2008

  • Descriptive modeling
    • Abstract, high-level, simple to communicate across the organization
    • Requires understanding of fundamental concepts such as pools and lanes, tasks and subprocesses and sequence flow, not the complexities of BPMN's various flow control and event patterns
  • Analytical modeling
    • More details, showing all the steps, including the exception paths required to analyze process performance using simulation or to create details requirements for an IT implementation. Requires understanding of BPMN's various decisions and merge patterns, event and exception handling patterns. Hierarchical representation of the end to end business process
  • Executable modeling
    • BPMN is a part of the executable process implementation. Imposes many validation constraints.
    • Modeling at this level is somewhat vendor tool-dependent.

Sub-models within an end-to-end BPMN model ⌘

  1. Processes (Orchestration)
    • Private non-executable (internal) Business Processes
    • ClipCapIt-171026-112123.PNG -> Private executable (internal) Business Processes
    • Public Processes
  2. Collaborations
  3. Choreographies
  4. Conversations

jBPM components ⌘

ClipCapIt-140916-144554.PNG

source: https://docs.jboss.org/jbpm

BPM tools ⌘

ClipCapIt-171026-112917.PNG

jBPM Workbench Overview ⌘

Starting jBPM console ⌘

 
cd /opt/jbpm-installer
ant start.demo

or

ant start.demo.noeclipse

Go to Firefox and type: http://localhost:8080/jbpm-console

Evaluation Demo ⌘

Evaluation.png

  • An employee performance needs to be evaluated
  • First, the employee gives feedback about their own performance
  • Later, HR (mary) and PM (john) departments give their opinion about employee department
  • It does not matter whether HR or PM evaluation is done first


Lab Executing Process in Kie ⌘

  1. localhost:8080/jbpm-console
  2. login krisv/krisv
  3. Build Project
    1. Got to Authoring/Project Autorining
    2. In Project Explorer select demo / jbpm-playground / Evaluation project
    3. Click BUSINESS PROCESSES / 'evaluation' process to view the diagram
    4. Click Open Project Editor / Build & Deploy
  4. Start an Process Instance
    1. Process Management / Process Definitions
    2. Actions / Start
    3. Employee: krisv (must be this user)
    4. Reason: evaluation

Lab Executing Process in Kie cont.⌘

  1. Perform Self-Evaluation
    1. Task List / Actions / Start
    2. Performance: "I am excellent"
  2. HR Evaluation
    1. Log in as mary
    2. Tasks / Actions / Start
    3. Click on Magnifying Glass icon / Work tab / Complete
  3. PM Evaluation
    1. Log in as john
    2. Task / Actions / Start
    3. Click on Magnifying Glass icon / Work tab / Complete
  4. View Log
    1. Process Management / Process Instances / Completed
    2. Actions / Details

Drools Overview ⌘

by Ronald Ross, Business Rule Concepts: Getting to the Point of Knowledge, 4th edition - BRS, 2013

Business Rules⌘

ClipCapIt-140905-143445.PNG

  • Rules are familiar to us all in real life.
  • We play games by rules, we live under a legal system based on rules, we set rules for our children, and so on.
  • Thinking about the control aspect of any organized activity in terms of rules is actually very natural (try explaining any game without explaining the rules the game is based).

What is a Business Rule?⌘

The SBVR follows a common-sense definition of ‘business rule’:

Business Rule: rule that is under business jurisdiction
  • ‘Under business jurisdiction’ means that the business can create, revise, and discontinue their business rules as they see fit.
  • If a rule is not under business jurisdiction in that sense, then it is not a business rule.
  • For example, the ‘law’ of gravity is obviously not a business rule. Neither are the ‘rules’ of mathematics.

Business Rule “Mantra”⌘

“Rules are based on facts, and facts are based on terms.”
RuleFactTerm.png

Terms

  • Employee
  • Employee number
  • Car
  • Car registration number

Facts

  • Car has car registration number
  • Employee drives car

Rules

  • Each employee must be uniquely identifiable.
  • Each car always has exactly one car registration number.

Artificial Intelligence ⌘

Drools-ai.jpg

  • Expert Systems are also known as Knowledge-based Systems and Knowledge-based Expert Systems
  • Drools is a Rule Engine that uses the rule-based approach to implement an Expert System and is more correctly classified as a Production Rule System.

Rule Engine ⌘

Drools-ruleengine.PNG

Drools documentation, Figure 1.1. High-level View of a Rule Engine

  • The Rules are stored in the Production Memory
  • Facts that the Inference Engine matches against are kept in the Working Memory.
  • Facts are asserted into the Working Memory where they may then be modified or retracted.
  • A system with a large number of rules and facts may result in many rules being true for the same fact assertion; these rules are said to be in conflict.
  • The Agenda manages the execution order of these conflicting rules using a Conflict Resolution strategy.

Advantages of a Rule Engine ⌘

  • Declarative Programming ("What", not "How")
  • Explanation Facility - we can see "how" engine solved the problem
  • Logic and Data Separation (breaking OO coupling of data and logic)
  • Speed and Scalability (Rete, Leaps, PHREAK)
  • Centralization of Knowledge (Documentation)
  • Tool Integration
  • Understandable Rules (DSL)

When should you use RE? ⌘

  • The problem may not be complex but there is no non-fragile way of building a solution for it
  • The problem is beyond any obvious algorithmic solution
  • The logic changes often
  • Domain experts (or business analysts) are readily available, but are nontechnical
  • There are too many rules to manage them in the code
  • We need rules to be explicit and documented

When shouldn't you use RE? ⌘

  • Maintaining the infrastructure is more expensive than the gains
  • With system which hardly ever change
  • There is no person understanding RE

Alternatives to Rule Engine ⌘

  • Scripting
  • Decision Tables (Lookup tables, DMN)
  • Other data-driven solutions

Rules Syntax ⌘

ClipCapIt-150708-182520.PNG
Rule "Next delegate discount"
   When
       $NumberOfDelegates > 1
   Then
       $Price = $Price - $Price*($numberOfDelegates-1)*10%
End

Domain Specific Language Rules⌘

ClipCapIt-171026-120855.PNG
  • DSL is a way non-technical people can write executable rules in Drools environment
  • DSL is ultimately transformed to rules (mvel or java)
  • .dsl file contain the transformations (mapping)

The Business Rules Manifesto ⌘

http://www.businessrulesgroup.org/brmanifesto.htm

Rules are not process and not procedure.  They should not be contained in either of these.
Rules build on facts, and facts build on concepts as expressed by terms.
If something cannot be expressed, then it is not a rule.
Business rules should be expressed in such a way that they can be validated for correctness by business people.
Exceptions to rules are expressed by other rules.