27
1 Developing Rules Driven Developing Rules Driven Workflows Workflows in Windows Workflow in Windows Workflow Foundation Foundation Jurgen Willis Jurgen Willis COM318 COM318 Program Manager Program Manager Microsoft Corporation Microsoft Corporation

1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

Embed Size (px)

Citation preview

Page 1: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

1

Developing Rules Driven Developing Rules Driven Workflows Workflows in Windows Workflow Foundationin Windows Workflow Foundation

Jurgen WillisJurgen WillisCOM318COM318Program ManagerProgram ManagerMicrosoft CorporationMicrosoft Corporation

Page 2: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

2

AgendaAgenda

Why Rules?Why Rules?

Activity Conditions + Dynamic Activity Conditions + Dynamic UpdateUpdate

Conditioned Activity GroupConditioned Activity Group

PolicyPolicy

Page 3: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

3

Windows Workflow FoundationWindows Workflow Foundation

Single workflow technology for Microsoft Single workflow technology for Microsoft products, partners and customersproducts, partners and customers

A framework to build on – not a server or applicationA framework to build on – not a server or application

Key featuresKey featuresEnables long running workflows in any application or Enables long running workflows in any application or serverserver

Extensible activity frameworkExtensible activity framework

Unified model for human and system workflow Unified model for human and system workflow scenariosscenarios

Visual designer for graphical and code-based Visual designer for graphical and code-based authoringauthoring

AvailabilityAvailabilityExposed via WinFX – powers Office “12” workflowExposed via WinFX – powers Office “12” workflow

Extensible framework and tools for building workflow into Windows applications

Page 4: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

4

Windows Workflow FoundationWindows Workflow FoundationKey ConceptsKey Concepts

Host Process

WindowsWorkflow Foundation

Runtime Engine

A Workflow

An Activity

Runtime Services

Base Activity Library

Custom Activity Library

Visual Designer

Visual Designer:Visual Designer: Graphical and Graphical and code-based constructioncode-based construction

WorkflowsWorkflows are a set of are a set of ActivitiesActivities

Workflows run within a Workflows run within a Host Host ProcessProcess: any application or : any application or serverserverDevelopers can build their own Developers can build their own Custom Activity LibrariesCustom Activity Libraries

ComponentsComponentsBase Activity Library:Base Activity Library: Out-of-box Out-of-box activities and base for custom activities and base for custom activitiesactivitiesRuntime Engine:Runtime Engine: Workflow Workflow execution and state managementexecution and state managementRuntime Services:Runtime Services: Hosting Hosting flexibility and communicationflexibility and communication

Page 5: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

5

Why Rules?Why Rules?

Modeling PowerModeling Power

ApproachabilityApproachability

Ease of ChangeEase of Change

Page 6: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

6

Model-driven development

Model-driven development

Rules and Application Rules and Application DevelopmentDevelopment

FormsForms

DataData

ApplicationApplicationlogiclogic

Rules andRules andpoliciespolicies

ApplicationApplicationcodecode

Workflow Workflow modelmodel

ServiceServicess

Page 7: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

7

Rules and WorkflowRules and WorkflowPolicy applied Policy applied to validate to validate orderorder

Condition Condition determines how to determines how to handle errorshandle errors

Rules determineRules determineorder routingorder routing

Page 8: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

8

TerminologyTerminology

ConditionConditionExpression that evaluates to True or Expression that evaluates to True or FalseFalse

RuleRuleModeled as:Modeled as:IFIF<Condition><Condition>

THENTHEN<Action(s)><Action(s)>

ELSEELSE<Action(s)> <Action(s)>

RuleSetRuleSetCollection of Rules with a set of Collection of Rules with a set of execution semanticsexecution semantics

Page 9: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

9

Workflow RulesWorkflow Rules

Conditions on activitiesConditions on activitiesIf-ElseIf-Else

WhileWhile

ReplicatorReplicator

Conditioned Activity Group (CAG)Conditioned Activity Group (CAG)

<Your custom activity><Your custom activity>

Policy activityPolicy activityContains and executes a RuleSetContains and executes a RuleSet

RuleSet execution provides priority-RuleSet execution provides priority-based, forward-chaining semantics based, forward-chaining semantics

Page 10: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

10

Rule ConditionsRule Conditions

Page 11: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

11

Dynamic UpdateDynamic Update

Add / remove Add / remove activitiesactivities

Modify rule Modify rule conditions on conditions on running workflow running workflow instancesinstances

Performed from Performed from code-beside or the code-beside or the hosthost

Can be disabled for Can be disabled for a workflow instancea workflow instance

Page 12: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

12

Dynamic UpdateDynamic Update

Page 13: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

13

Conditioned Activity Conditioned Activity Group Group (CAG)(CAG)

Flexible, rule-driven activity Flexible, rule-driven activity executionexecutionModeling of activity sets with Modeling of activity sets with numerous sequencing numerous sequencing permutationspermutations

MotivationMotivation

Stage-Gate patternStage-Gate patternCollaborative tasksCollaborative tasksScenariosScenarios

Page 14: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

14

CAG - OverviewCAG - OverviewChild activity executesChild activity executes

When(Condition1)When(Condition1)

CAG executesCAG executesUntil(Condition2)Until(Condition2)

Default execution is a parallelDefault execution is a parallelWhenWhen

Executes activity onceExecutes activity once

UntilUntil““All children quiescent”All children quiescent”

Executing children complete and all When Executing children complete and all When conditions == falseconditions == false

Conceptually, an activity executes:

IF When && !(Until)

Child activities

Page 15: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

15

CAG - Overview CAG - Overview

ReevaluationReevaluationWhen immediate child moves to When immediate child moves to completed statecompleted state

Define custom Until condition to Define custom Until condition to short-circuit CAG executionshort-circuit CAG execution

No new activities executedNo new activities executed

Blocked activities cancelledBlocked activities cancelled

Page 16: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

16

Conditioned Activity GroupConditioned Activity Group

Page 17: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

17

PolicyPolicy

Separation of business logic from Separation of business logic from application sequencingapplication sequencingDeclarative statements of business Declarative statements of business intentintentExecution semantics to support rich Execution semantics to support rich sets of business logicsets of business logic

MotivationMotivation

ScenariosScenariosOrder validationOrder validationWarranty claims managementWarranty claims managementDiscount calculationDiscount calculation

Page 18: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

18

What about the BizTalk BRE? What about the BizTalk BRE?

BizTalk Business Rules EngineBizTalk Business Rules EngineThe next major version of BizTalk (post-The next major version of BizTalk (post-BizTalk 2006) will be built on Windows BizTalk 2006) will be built on Windows Workflow FoundationWorkflow Foundation

Windows Workflow Foundation will provide Windows Workflow Foundation will provide the core rules engine evaluator and the core rules engine evaluator and developer toolsdeveloper tools

BizTalk will provide premium tooling and BizTalk will provide premium tooling and server infrastructure, e.g.:server infrastructure, e.g.:

Business analyst toolsBusiness analyst tools

RuleSet storage and managementRuleSet storage and management

RuleSet analysisRuleSet analysis

Page 19: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

19

Policy OverviewPolicy Overview““Policy” activity used as base type Policy” activity used as base type for custom activityfor custom activity

RuleSet class contains a collection of RuleSet class contains a collection of RulesRules

Rules are If-Then-Else expressions Rules are If-Then-Else expressions that evaluate and operate on activity that evaluate and operate on activity propertiesproperties

Expressions are CodeDom basedExpressions are CodeDom based

Priority value can be used to order Priority value can be used to order rule evaluationrule evaluation

Page 20: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

20

PolicyPolicy

Page 21: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

21

Amount = $25 Amount = $25 Total = $80Total = $80DiscountDiscount = 10%= 10%

Rule 1 (P0)Rule 1 (P0)IfIf Total > $50 & < $100 Total > $50 & < $100

ThenThen Discount = 10% Discount = 10%

Rule 2 (P0)Rule 2 (P0)IfIf Total >= $100Total >= $100

ThenThen Discount = 15% Discount = 15%

Rule 3 (P0)Rule 3 (P0)IfIf Amount > $0Amount > $0

ThenThen Total = Total + Total = Total + AmountAmount

Forward Chaining ExampleForward Chaining Example

Rule 1Rule 1

Rule 3 Rule 3

Rule 2Rule 2

Execution Sequence

$105$105

RuleSet

15%15%

Page 22: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

22

RuleSet ChainingRuleSet ChainingChaining MechanismsChaining Mechanisms

Implicit based on property usageImplicit based on property usage

Explicit using Update statementExplicit using Update statement

““Partially explicit” using method Partially explicit” using method attributesattributes

Additional PointsAdditional PointsMaximum execution count propertyMaximum execution count property

Halt statementHalt statement

Page 23: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

23

Policy ExtensibilityPolicy Extensibility

Page 24: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

24

SummarySummary

Integrated workflow and rules Integrated workflow and rules capabilitycapability

Flexible forward chaining rules Flexible forward chaining rules engineengine

Rules + dynamic update => flexible Rules + dynamic update => flexible workflow definition and controlworkflow definition and control

Page 25: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

25

Workflow SessionsWorkflow Sessions

Extending Workflow Capabilities With Custom Activities (COM328)Wed 3:15 – 150/151 Hall E

Developing Rules-Driven Workflows (COM318)Wed 5:00 – 152/153 Hall F

Developing Event-Driven State Machine Workflows (COM322) Thurs 2:15 – 515 AB

Hosting and Communications in Workflow Scenarios (COM327)Thurs 5:15 – 402 AB

Workflow + Messaging + Services - Developing Dist’d Apps (COM325)Thurs 3:45 – 150/151 Hall E

Host Process

WindowsWorkflow Foundation

Runtime Engine

Runtime Services

Base Activity Library

My Custom Activity Library

State Machine Workflows

Rules-Driven Activities

Communication Activities

My WorkflowsIntroduction to Workflow in Windows Applications (COM210)Wed 1:45 – 150/151 Hall E

Windows CommunicationFoundation

Windows SharePoint Services: Developing Custom Workflows (OFF415) Thurs 11:30 – 408 AB

Hands-on Labs!

Page 26: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

26

More Community More Community ResourcesResourcesAt PDCAt PDC

12 Labs: COMHOL01-1212 Labs: COMHOL01-12““Ask The Experts” tables – 4 tables and lots of Ask The Experts” tables – 4 tables and lots of expertsexpertsCOM Track LoungeCOM Track LoungeGet your copy of the “Presenting Windows Get your copy of the “Presenting Windows Workflow Foundation” bookWorkflow Foundation” book

Keep your voucher from today’s keynote and redeem at Keep your voucher from today’s keynote and redeem at the PDC bookstorethe PDC bookstore

After PDCAfter PDCIf you missed a related session, watch it on the If you missed a related session, watch it on the DVDDVDMSDN dev center: MSDN dev center: http://msdn.microsoft.com/workflowWindows Workflow Foundation community site Windows Workflow Foundation community site http://www.windowsworkflow.nethttp://www.windowsworkflow.net Channel 9 tag: Channel 9 tag: http://channel9.msdn.com/tags/workflowhttp://channel9.msdn.com/tags/workflow

Page 27: 1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation

27

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.