The world of .NET from a Connected Systems MVP & INETA Speaker

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
  • 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
  • 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
  • OOB Activities
    • Grouped into
      • Flow
      • State-Based
      • Rule-based
      • Communication
      • Misc.
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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)
  • You must...
    • Some services are required, defaults will be used if not configured
      • Scheduler
      • Batch (transactions)
      • WorkflowLoading
  • If you build it...
    • Runtime will automatically use certain services if found (discover based on base class)
      • Tracking
      • Persistence
  • OOB implementations
    • Many optional services have OOB implementations
      • SqlWorkflowPersistenceService
      • SqlTrackingService
  • Custom services
    • Custom services likely for most WF usage models
      • Custom tracking
      • Persistence
      • Other "services" needed by Actvities added to runtime by hosting environment
  • 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
  • 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
  • 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
  • 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
  • Designer
    • Visual creation of workflows
      • Designer built into Visual Studio
      • Designer can be hosted as control in other apps
      • Themed (custom themes possible)
  • 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)
  • 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
  • WFC
    • Workflow compiler
      • Used to compile XAML-or code-based workflows
      • Can compile XAML and "code behind"
      • Outputs assembly
  • Not all XAML is created equal
    • XAML can either be executed (CreateWorkflow) or compiled - not both
      • Presence of Class attribute is key factor
  • 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
  • Why Workflow?
    • Many applications' logic are really workflows
      • Web app page flow
      • Form wizards
      • Service compositors
      • Long-running processes
  • 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

» Similar Posts

  1. Windows Workflow 103 or WF Part 3 - Introduction to Workflow
  2. Windows Workflow 101 or 2 Months with WF
  3. Windows Workflow 104 or WF Part 4

» Trackbacks & Pingbacks

    No trackbacks yet.
Trackback link for this post:
http://samgentile.com/Web/trackback.ashx?id=1281

» Comments

    There are no comments. Kick things off by filling out the form below.

» Leave a Comment