Post on 03-Jan-2016
Building State Machine Workflows with Windows Workflow Foundation
Ron JacobsSr. Program ManagerMicrosoft
MID305
AppFabric / Host
WF Runtime Extensions
Tracking
Persistence
…
Windows Workflow Foundation
Windows Workflow Foundation provides declarative authoring of programs that coordinate work
ActivitiesRuntimeTooling
Tooling
VS Designer VS DebuggerRehosted Designer
Workflow
Activity Library
State Machine
“It is a behavior model composed of a finite number of states, transitions between those states, and actions, similar to a flow graph in which one can inspect the way logic runs when certain conditions are met.”
Wikipedia – Finite State Machine
States
Closed
Open
Open
Closed
State Transition
States
Closed / Locked
Closed / UnlockedOpen
Insert Card
Open
Close
Authorized?
Control Flow
ControlReact
State Machine Flowchart Sequence
Which one should I use?
State Machine in the real world
Load
Delivered
Picked Up
Rec
eive
d
Repair
Order
Proof Of Delivery(EPOD)
Proof Of Collection(EPOC)
Proof Of Dispatch(EPOD)
Security Door Requirements
Authorize Card KeysLog Door Open/Close EventsWarn Security When Door is open too long
• AuthorizeKey• DoorOpened• DoorClosed
demo
Security Door
how to…
Seven Steps
To State Machine Happiness
Step 1: .NET Platform Update 1
Microsoft .NET Framework 4 Platform Update 1 – Design-time Package for Visual Studio 2010 SP1 (KB2495593)
Installs the everything and configures Visual Studio.
Microsoft .NET Framework 4 Platform Update 1 (KB2478063)
Contains the runtime files for the platform update.Use for production environments
Step 2: Hands On Lab
Introduction to State Machine Hands On Lab
Step 3: Target Framework
Web Apps / Workflow Services All Others
Step 4: Scenarios
Given When ThenA Closed Locked Door
An Authorized Card Key Is Read
Unlock the door
A Closed Locked Door
An Unauthorized Card Key is Read
Log the event
A Closed Unlocked Door
The Door Is Opened Log the event
An Open Door The Door Open Timeout Expires
Send an alert to security
An Open Door The Door Is Closed Log the event
Step 4: States / Transitions
States are destinations where you waitDoor Closed / Door OpenCreate an enum or constants to describe your states in code
Transitions are events where you respondTip: One Trigger per TransitionTriggers
Card InsertedOpen Timeout
ConditionsCard Authorized
Step 5: Actions
Entry / ExitDo every time you enter / exit the state
TransitionDo every time the trigger event occurs and the condition is met
Step 6: Tests
Get Microsoft.Activities.UnitTesting (Now via NuGet!)Create your tests as you build your scenariosStub calls to external systemsLearn to love Red / Green / Refactor
Unit Tests included in the Introduction to State Machine Hands On Lab
Step 7: Follow
Blogsappfabric.tvAppFabricRon Jacobs
Twitter@appfabric@ronljacobs
FacebookAppfabricRon Jacobs
demo
ATM State Machine
Related Content
Interactive SessionsWindows Workflow Foundation (WF) 4.0 in the Real World: Principles for Incorporating WF 4.0 into the Big Enterprise
Hands-on LabsIntroduction to State Machine
Product Demo StationsMiddleware & Integration booth 14
Track Resources
Windows Azure Platform Training Kit
Windows Server AppFabric Training Kit
BizTalk 2010 Developer Training Kit
Windows Azure AppFabric on MSDN
Windows Server AppFabric on MSDN
AppFabric Team Blog
Resources
www.microsoft.com/teched
Sessions On-Demand & Community Microsoft Certification & Training Resources
Resources for IT Professionals Resources for Developers
www.microsoft.com/learning
http://microsoft.com/technet http://microsoft.com/msdn
Learning
http://northamerica.msteched.com
Connect. Share. Discuss.
Complete an evaluation on CommNet and enter to win!
Scan the Tag to evaluate this session now on myTech•Ed Mobile
© 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.