380 likes | 601 Views
TOOL-801T. Building event-driven, long-running apps with Windows workflow. Ron Jacobs Sr. Program Manager Microsoft Corporation. www.ronjacobs.com. Agenda. Some thoughts on "event-driven" and "long-running" Two Server Scenarios Job Application Mortgage Application One Client Scenario
E N D
TOOL-801T Building event-driven, long-running apps with Windows workflow Ron Jacobs Sr. Program Manager Microsoft Corporation www.ronjacobs.com
Agenda • Some thoughts on "event-driven" and "long-running" • Two Server Scenarios • Job Application • Mortgage Application • One Client Scenario • ATM Machine
Event Driven Something Happens Something Responds Work gets done
Event Driven Query status for order Query database and return status Display status to user
Event Driven / Long Running Submit Job Application Save in database and return ID Display ID for user Send Email to HR Wait… No response Send another mail Wait… HR responds to email Save in database and return status Send Email to applicant Complete
Windows Workflow Foundation provides a programming model to support long running event driven work
Windows Server AppFabric Workflow
Activity • Authored in XAML • Composition of other activities • Distribution • Compiled into an assembly with generated helpers • Loaded from stream (file system, database, service etc.)
Activity • publicclassDebugTrace : CodeActivity{ • publicInArgument<string> Text { get; set; } • protectedoverridevoidExecute(CodeActivityContext context) {Debug.WriteLine(Text.Get(context)); • } • }
Control Flow Which one should I use? Control React Flowchart Sequence State Machine
A Lap Around WF 4.5Key new features Authoring Improvements Versioning Runtime Enhancements
Application Process Education Service Applicant 1 Applicant Service HR Data 2 Persistence 3 6 4 Reviewer 5 AppFabric Cache
demo Job Application
To properly version long running processes both behavior and data must have a version
WF 3.5 Persistence Workflow Definition (XAML) Workflow Definition (XAML) Instance Data Instance Data Instance Store
WF 4 Persistence Workflow Definition (XAML) Instance Data Instance Data Instance Store
WF 4 Persistence Exception (?) Workflow Definition (XAML) Workflow (v2) Instance Data (v?) Instance Data Instance Store
WF 4 Persistence Workflow (v2) Instance Data (v?) Instance Data Instance Store
Workflow Identity “My Workflow”1.0.0.0 Instance Data for “My Workflow” 1.0.0.0 Instance Data (1.0.0.0) Instance Store
Workflow Identity Exception (Version Mismatch) “My Workflow”1.0.0.0 “My Workflow”2.0.0.0 Instance Data for “My Workflow” 1.0.0.0 Instance Data (1.0.0.0) Instance Store
WorkflowIdentity • var identity = newWorkflowIdentity("My Workflow", newVersion(1, 0, 0, 0)); • var workflow = newWorkflowApplication(newActivity1(), identity); • workflow.Run();
WorkflowApplicationInstance • // get the instance data but do not bind to definition • varinstance = WorkflowApplication.GetInstance(instanceId, instanceStore); • // get the definition associated to the identity • vardefinition = definitions[instance.DefinitionIdentity];
Demo Workflow Identity
Create Update Map “My Workflow”1.0.0.0 “My Workflow”2.0.0.0
Apply Update Map Instance Data for “My Workflow” 2.0.0.0 Instance Data for “My Workflow” 1.0.0.0
Dynamic Update • // Create the update map • DynamicUpdateMapmap = DynamicUpdateServices.CreateUpdateMap(definition);
Dynamic Update • instance = WorkflowApplication.GetInstance(id, CreateInstanceStore()); • application = newWorkflowApplication(targetActivity, targetIdentity); • // apply the update to the instance • application.Load(instance, this.currentUpdateMap); • application.Unload();
Demo Dynamic Update
ATM State Machine • Model business process as a series of states and transitions • Example from State Machine Hands On Lab • WPF Application • Model / View / View Model pattern
Demo State Machine
HTTP Messaging • Request / response messaging built on the WCF WebApi stack • Prototype available • http://wf.codeplex.com
For more information RELATED SESSIONS DOCUMENTATION & ARTICLES • Workflow and Windows Azure • What's New with Workflow 4.5 • Activities, Extensions, Tools available at • http://wf.CodePlex.com
thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback
© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.