Live Blog - Day 3 Pluralsight BizTalk Course - Introduction to Windows Workflow Foundation
I thought today may be a good topic for my audience as it go well together with my 3 part WF series just as some of yesterday augments this post on WCF 101.
- WF Windows Workflow Foundation
- WF is a Framework for building Workflow-enabled applications
- It is NOT a Workflow "product"
- CLR-based extensible framework
- Re-hostable runtime and toolset (design tools, compiler)
- Royalty-free
- Part of .NET 3.0
- Ships in Windows Vista
- WF is a Framework for building Workflow-enabled applications
- Microsoft's Workflow Engine
- WF will be the workflow engine for all workflow-enabled Microsoft products going forward
- Windows SharePoint Services 3.0
- Speech Server
- BizTalk Server 200x
- All future products requiring workflow capabilities
- WF will be the workflow engine for all workflow-enabled Microsoft products going forward
- Activity
- Base class of all base classes in WF
- A Workflow is a tree of Activities
- An Activity is the atom of execution
- WF includes a rich set of built-in Actvities
- Custom Activities are almost a certainty for any application that uses WF
- Base class of all base classes in WF
- OOB Activities
- Grouped into
- Flow
- State-Based
- Rule-based
- Communication
- Misc.
- Grouped into
- Activities and the Runtime
- WorkflowRuntime can operate on any single valid Activity
- It doesn't differentiate one Activity from another
- Most apps will execute on an Activity which is a composite
- Child Actvities executed by parent
- WF comes with two typical "root" models
- WorkflowRuntime can operate on any single valid Activity
- SequentialWorkflowActvity
- One of two built-in top-level Actvities
- Path of execution is more predetermined
- Contains other Activities
- Useful model when workflow needs to be in charge of execution path
- Example: Document-approval workflow with limited steps
- One of two built-in top-level Actvities
- StateMachineWorkflowActivity
- Modeled as a set of distinct states
- State transitions used to move from one possible state to another
- Useful model when user or host needs to have influence on execution path
- Example: Document-approval with a dynamic number of steps
- Modeled as a set of distinct states
- Rules
- WF contains a full-featured rule engine
- Rule-based conditions
- Policy Activity
- Custom rule-based Activities possible
- Dynamic execution model enables runtime changes
- Rule-based model useful for many algorithms
- WF contains a full-featured rule engine
- WorkflowRuntime
- Controls execution of workflows with a very specific model
- Provides access to services
- Mediates communication between host and workflow
- Creates and manages workflow instances
- Host controls workflow usage through WorkflowRuntime Type
- Host plays a significant role in the behavior of the WorkflowRuntime
- Controls execution of workflows with a very specific model
- Services
- Runtime relies on services
- IServiceProvider model
- Services are singletons per WorkflowRuntime
- Well-known services derive from WorkflowRuntimeService and derived classes
- Can be done with code or config
- Any type can be a service (Runtime needed to know about all services)
- Runtime relies on services
- You must...
- Some services are required, defaults will be used if not configured
- Scheduler
- Batch (transactions)
- WorkflowLoading
- Some services are required, defaults will be used if not configured
- If you build it...
- Runtime will automatically use certain services if found (discover based on base class)
- Tracking
- Persistence
- Runtime will automatically use certain services if found (discover based on base class)
- OOB implementations
- Many optional services have OOB implementations
- SqlWorkflowPersistenceService
- SqlTrackingService
- Many optional services have OOB implementations
- Custom services
- Custom services likely for most WF usage models
- Custom tracking
- Persistence
- Other "services" needed by Actvities added to runtime by hosting environment
- Custom services likely for most WF usage models
- Communication
- Runtime must control between host and workflow
- The runtime model requires the ability to persist at any time
- Host can't have real reference to workflow objects
- Communication enabled through queues
- Higher-level abstractions built on top of queues
- Data must be serialized
- Runtime must control between host and workflow
- Hosting
- The layer of code that uses the WorkflowRuntime
- Can be any-CLR enabled app
- No standard default host
- Host is app-specific
- A basic WebService (asmx) host is provided
- Host responsible for bootstrapping the WorkflowRuntime
- Host is responsible for adding services
- The layer of code that uses the WorkflowRuntime
- Workflow Execution
- Host must create workflows through the runtime
- WorkflowRuntime.CreateWorkflow can take any type if Activity (i.e. Workflow need not be just StateMachine or Sequential)
- WorkflowRuntime.CreateWorkflow overload takes XAML (XmlReader)
- WorkflowInstance can be used to start workflow
- Host must create workflows through the runtime
- Parameters
- Parameters are passed to a workflow when created
- Dictionary<string,object> is container
- Workflow defines public properties
- A read-only copy of properties available after workflow completion
- Parameters are passed to a workflow when created
- Designer
- Visual creation of workflows
- Designer built into Visual Studio
- Designer can be hosted as control in other apps
- Themed (custom themes possible)
- Visual creation of workflows
- Compilation
- Workflows can be expressed in code
- Activity tree compiled into assembly
- Executed by loading .NET type
- VS.NET designer uses typical model (InitializeComponent to create tree)
- Workflows can be expressed in code
- XAML
- Workflows can be expressed in XAML (XML markup)
- Key for workflow apps (ease of authoring)
- Ease of use in dynamic situations
- You will beed code-based Activities more than if using compiled workflows
- WorkflowRuntime can create workflows from an XmlReader
- Workflows can be expressed in XAML (XML markup)
- WFC
- Workflow compiler
- Used to compile XAML-or code-based workflows
- Can compile XAML and "code behind"
- Outputs assembly
- Workflow compiler
- Not all XAML is created equal
- XAML can either be executed (CreateWorkflow) or compiled - not both
- Presence of Class attribute is key factor
- XAML can either be executed (CreateWorkflow) or compiled - not both
- Dynamic Change
- In-Memory workflows can be modified
- Activities can be added or removed
- Adaptive scenarios possible (e.g. escalation)
- Change affects single Activity
- Changed Activity *could* be persisted (into an assembly or as markup)
- XAML-based workflows must be appropriate for planned dynamic change
- In-Memory workflows can be modified
- Why Workflow?
- Many applications' logic are really workflows
- Web app page flow
- Form wizards
- Service compositors
- Long-running processes
- Many applications' logic are really workflows
- Workflow Possibilities
- WF is a multi-purpose runtime for executing code
- Could be used for a simple workflow inside of an application (algorithm usage)
- Customizable and/or dynamic workflow system
- Vertical or Horizontal Workflow Product (including Microsoft projects
- WF is a multi-purpose runtime for executing code
Filed under: BizTalk
