Building event-driven, long-running apps with Windows workflow 12/5/2018 9:47 PM TOOL-801T Building event-driven, long-running apps with Windows workflow Ron Jacobs Sr. Program Manager Microsoft Corporation www.ronjacobs.com © 2010 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.
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
Query database and return status 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
Workflow Windows Server AppFabric
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 public class DebugTrace : CodeActivity { public InArgument<string> Text { get; set; } protected override void Execute( CodeActivityContext context) { Debug.WriteLine(Text.Get(context)); } © 2010 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.
Control Flow Which one should I use? Control React State Machine Flowchart Sequence
A Lap Around WF 4.5 Key new features Ask Feature Expressions in the language of the project C# expressions Create workflow services based on an existing contract Contract-First Better experience with Flowchart / State Machine designer Auto-connect, auto-insert, pan Add comments to activities in the designer surface Annotations (designer) Search integration in the workflow designer Search (designer) Invalid workflows should cause build errors Validation errors break build Authoring Improvements Basic building blocks for a versioning story WorkflowIdentity Host several versions of a service side by side WFSH versioning support Update running instances to a new definition Dynamic Update Versioning Run my workflows in Partial Trust Partial Trust Be able to plug my own expressions story Expressions Extensibility Better runtime performance VB expressions performance Runtime Enhancements
Application Process AppFabric Cache HR Data Persistence Applicant 1 Service 2 3 Education Service 6 4 5 Reviewer
demo Job Application 12/5/2018 9:47 PM © 2010 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.
Versioning and Dynamic Update
To properly version long running processes both behavior and data must have a version
WF 3.5 Persistence Workflow Definition (XAML) Instance Data Instance Store
WF 4 Persistence Workflow Definition (XAML) Instance Data Instance Store
WF 4 Persistence Exception (?) Workflow Definition Workflow (v2) (XAML) Workflow (v2) Instance Data (v?) Instance Data Instance Store
WF 4 Persistence Workflow (v2) Instance Data (v?) Instance Store
Workflow Identity “My Workflow” 1.0.0.0 Instance Data for Instance Store
Workflow Identity Exception (Version Mismatch) “My Workflow” 1.0.0.0 Instance Data for “My Workflow” 1.0.0.0 Instance Data (1.0.0.0) Instance Store
WorkflowIdentity var identity = new WorkflowIdentity("My Workflow", new Version(1, 0, 0, 0)); var workflow = new WorkflowApplication( new Activity1(), identity); workflow.Run(); © 2010 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.
WorkflowApplicationInstance // get the instance data but do not bind to definition var instance = WorkflowApplication.GetInstance( instanceId, instanceStore); // get the definition associated to the identity var definition = definitions[instance.DefinitionIdentity]; © 2010 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.
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” 1.0.0.0 2.0.0.0
Dynamic Update // Create the update map DynamicUpdateMap map = DynamicUpdateServices.CreateUpdateMap(definition); © 2010 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.
Dynamic Update instance = WorkflowApplication.GetInstance(id, CreateInstanceStore()); application = new WorkflowApplication(targetActivity, targetIdentity); // apply the update to the instance application.Load(instance, this.currentUpdateMap); application.Unload(); © 2010 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.
Demo Dynamic Update
State Machine
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 and Workflow
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 feedback http://bldw.in/SessionFeedback
12/5/2018 9:47 PM © 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. © 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.