280 likes | 637 Views
Developing Rules Driven Workflows in Windows Workflow Foundation. Jurgen Willis COM318 Program Manager Microsoft Corporation. Agenda. Why Rules? Activity Conditions + Dynamic Update Conditioned Activity Group Policy. Windows Workflow Foundation.
E N D
Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation
Agenda • Why Rules? • Activity Conditions + Dynamic Update • Conditioned Activity Group • Policy
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
Windows Workflow Foundation Visual Designer Workflows are a set of Activities Key Concepts AWorkflow Workflows run within a Host Process: any application or server Developers can build their own Custom Activity Libraries AnActivity Custom Activity Library Components Windows Workflow Foundation Base Activity Library:Out-of-box activities and base for custom activities Base Activity Library Runtime Engine:Workflow execution and state management Runtime Engine Runtime Services:Hosting flexibility and communication Runtime Services Visual Designer:Graphical and code-based construction Host Process
Modeling Power Approachability Ease of Change Why Rules?
Rules and policies Forms Workflow model Application code Data Services Rules and Application Development Model-driven development Application logic
Rules and Workflow Policy applied to validate order Condition determines how to handle errors Rules determine order routing
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
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
Dynamic Update • Add / remove activities • Modify rule conditions on running workflow instances • Performed from code-beside or the host • Can be disabled for a workflow instance
Conditioned Activity Group (CAG) Flexible, rule-driven activity execution Modeling of activity sets with numerous sequencing permutations Motivation Stage-Gate pattern Collaborative tasks Scenarios
CAG - Overview Child activities • Child activity executes • When(Condition1) • CAG executes • Until(Condition2) • Default execution is a parallel • When • Executes activity once • Until • “All children quiescent” • Executing children complete and all When conditions == false Conceptually, an activity executes: IF When && !(Until)
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
Policy Separation of business logic from application sequencing Declarative statements of business intent Execution semantics to support rich sets of business logic Motivation Order validation Warranty claims management Discount calculation Scenarios
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
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
Rule 1 (P0) If Total > $50 & < $100 Then Discount = 10% Rule 2 (P0) IfTotal >= $100 Then Discount = 15% Rule 3 (P0) IfAmount > $0 Then Total = Total + Amount Rule 1 Rule 3 Rule 2 Forward Chaining Example Execution Sequence RuleSet Amount = $25 Total = $80 Discount $105 15% = 10%
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
Summary • Integrated workflow and rules capability • Flexible forward chaining rules engine • Rules + dynamic update => flexible workflow definition and control
Hands-on Labs! Workflow Sessions Introduction to Workflow in Windows Applications (COM210) Wed 1:45 – 150/151 Hall E My Workflows My Custom Activity Library Extending Workflow Capabilities With Custom Activities (COM328) Wed 3:15 – 150/151 Hall E Windows Workflow Foundation Developing Rules-Driven Workflows (COM318) Wed 5:00 – 152/153 Hall F Base Activity Library State Machine Workflows Windows SharePoint Services: Developing Custom Workflows (OFF415) Thurs 11:30 – 408 AB Rules-Driven Activities Communication Activities Developing Event-Driven State Machine Workflows (COM322) Thurs 2:15 – 515 AB Runtime Engine Runtime Services Workflow + Messaging + Services - Developing Dist’d Apps (COM325) Thurs 3:45 – 150/151 Hall E Windows Communication Foundation Hosting and Communications in Workflow Scenarios (COM327) Thurs 5:15 – 402 AB Host Process
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
© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.