Rules Driven Workflows

Download Report

Transcript Rules Driven Workflows

Developing Rules Driven Workflows
in Windows Workflow Foundation
Jurgen Willis
COM318
Program Manager
Microsoft Corporation
1
Agenda
Why Rules?
Activity Conditions + Dynamic Update
Conditioned Activity Group
Policy
2
Windows Workflow Foundation
Extensible framework and tools for building
workflow into Windows applications
Single workflow technology for Microsoft products,
partners and customers
A framework to build on – not a server or application
Key features
Enables long running workflows in any application or server
Extensible activity framework
Unified model for human and system workflow scenarios
Visual designer for graphical and code-based authoring
Availability
Exposed via WinFX – powers Office “12” workflow
3
Windows Workflow Foundation
Key Concepts
Workflows are a set of Activities
Workflows run within a Host
Process: any application or server
Developers can build their own
Custom Activity Libraries
Components
Base Activity Library: Out-of-box
activities and base for custom activities
Runtime Engine: Workflow execution
and state management
Runtime Services: Hosting flexibility
and communication
Visual Designer: Graphical and codebased construction
Visual Designer
A Workflow
An Activity
Custom Activity Library
Windows
Workflow Foundation
Base Activity Library
Runtime Engine
Runtime Services
Host Process
4
Why Rules?
Modeling Power
Approachability
Ease of Change
5
Rules and Application
Development
Rules and
policies
Forms
Workflow
model
Application
code
Application
logic
Data
Services
6
Rules and Workflow
Condition determines
how to handle errors
Policy applied to
validate order
Rules determine
order routing
7
Terminology
Condition
Expression that evaluates to True or False
Rule
Modeled as:
IF<Condition>
THEN<Action(s)>
ELSE<Action(s)>
RuleSet
Collection of Rules with a set of execution
semantics
8
Workflow Rules
Conditions on activities
If-Else
While
Replicator
Conditioned Activity Group (CAG)
<Your custom activity>
Policy activity
Contains and executes a RuleSet
RuleSet execution provides priority-based,
forward-chaining semantics
9
Rule Conditions
10
Dynamic Update
Add / remove
activities
Modify rule conditions
on running workflow
instances
Performed from codebeside or the host
Can be disabled for a
workflow instance
11
Dynamic Update
12
Conditioned Activity Group
(CAG)
Motivation
Flexible, rule-driven activity
execution
Modeling of activity sets with
numerous sequencing permutations
Scenarios
Stage-Gate pattern
Collaborative tasks
13
CAG - Overview
Child activity executes
Child activities
When(Condition1)
CAG executes
Until(Condition2)
Default execution is a parallel
When
Executes activity once
Until

Conceptually, an
activity executes:
IF When && !(Until)
“All children quiescent”
Executing children complete and all When
conditions == false
14
CAG - Overview
Reevaluation
When immediate child moves to
completed state
Define custom Until condition to
short-circuit CAG execution
No new activities executed
Blocked activities cancelled
15
Conditioned Activity Group
16
Policy
Motivation
Scenarios
Separation of business logic from
application sequencing
Declarative statements of business
intent
Execution semantics to support rich sets
of business logic
Order validation
Warranty claims management
Discount calculation
17
What about the BizTalk BRE?
BizTalk Business Rules Engine
The next major version of BizTalk (post-BizTalk
2006) will be built on Windows Workflow
Foundation
Windows Workflow Foundation will provide the
core rules engine evaluator and developer tools
BizTalk will provide premium tooling and server
infrastructure, e.g.:
Business analyst tools
RuleSet storage and management
RuleSet analysis
18
Policy Overview
“Policy” activity used as base type for
custom activity
RuleSet class contains a collection of
Rules
Rules are If-Then-Else expressions that
evaluate and operate on activity properties
Expressions are CodeDom based
Priority value can be used to order rule
evaluation
19
Policy
20
Forward Chaining Example
Execution Sequence
RuleSet
Rule 1 (P0)
If Total > $50 & < $100
Then Discount = 10%
Rule 1
Rule 3
Rule 2
Rule 2 (P0)
If Total >= $100
Then Discount = 15%
Rule 3 (P0)
If Amount > $0
Then Total = Total + Amount
Amount = $25
Total = $80 $105
Discount = 10% 15%
21
RuleSet Chaining
Chaining Mechanisms
Implicit based on property usage
Explicit using Update statement
“Partially explicit” using method attributes
Additional Points
Maximum execution count property
Halt statement
22
Policy Extensibility
23
Summary
Integrated workflow and rules capability
Flexible forward chaining rules engine
Rules + dynamic update => flexible
workflow definition and control
24
Workflow Sessions
Introduction to Workflow in Windows
Applications (COM210)
Wed 1:45 – 150/151 Hall E
Hands-on Labs!
My Workflows
Extending Workflow Capabilities With
Custom Activities (COM328)
Wed 3:15 – 150/151 Hall E
Developing Rules-Driven Workflows
(COM318)
My Custom Activity Library
Wed 5:00 – 152/153 Hall F
State Machine Workflows
Windows SharePoint Services: Developing
Custom Workflows (OFF415)
Thurs 11:30 – 408 AB
Developing Event-Driven State Machine
Workflows (COM322)
Thurs 2:15 – 515 AB
Workflow + Messaging + Services Developing Dist’d Apps (COM325)
Thurs 3:45 – 150/151 Hall E
Hosting and Communications in Workflow
Scenarios (COM327)
Thurs 5:15 – 402 AB
Windows
Workflow Foundation
Base Activity Library
Rules-Driven Activities
Communication Activities
Runtime Engine
Runtime Services
Windows Communication
Foundation
Host Process
25
More Community Resources
At PDC
12 Labs: COMHOL01-12
“Ask The Experts” tables – 4 tables and lots of experts
COM Track Lounge
Get your copy of the “Presenting Windows Workflow
Foundation” book
Keep your voucher from today’s keynote and redeem at the PDC
bookstore
After PDC
If you missed a related session, watch it on the DVD
MSDN dev center:
http://msdn.microsoft.com/workflow
Windows Workflow Foundation community site
http://www.windowsworkflow.net
Channel 9 tag:
http://channel9.msdn.com/tags/workflow
26
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
27