Workflow Foundation

Features

Business Rules

Rules are not directly supported in WF 4. To use these, reference WF 1 (.NET 3.5) libraries.

Rules samples (link).

Introduction to the Windows Workflow Foundation Rules Engine (link).

Windows Workflows: Rules and Conditions article on OdeToCode (link), 2006-08-31.

Dynamic Update

Modifying workflows on the fly - myth or a reality? You can modify workflows on the fly using the technique below (Loading from XAML). To modify a workflow service that uses persistence the preferred technique is to create a new version of the workflow and apply routing rules to redirect new requests to use the new endpoint.

See some answers at the following discussion on Microsoft forums - here (versioning in WF 4 services when they are persisted).

Loading from XAML (link on MSDN).

Referencing Dynamic Activities: Reusing Workflow Activities Without Compilation (link).

See Routing below.

Patterns

There is an initial list of patterns used with WF in MSDN Magazine article - (link).

Persistence

How to enable SQL persistence (link).

Delay/Timers

Persisted workflows with Delay activities (timers) will get shut down by IIS after the site timeout period expires. When that occurs, no due timers will trigger. As the site is shut down it will not process any workflows that have the timers due. The Service site will have to be "awaken" by another service call.

Increasing the site timeout value is a good start. The maximum value for this is 30 days (43200 minutes).

Reference: link.

After a site restart (or apppool restart, whether web.config update, redeployment, or just a site restart after being put to sleep) the workflow delay processing will not continue automatically. So, make sure you wake up your service after redeployment.

Routing (Versioning in v4)

WCF Routing seems to be the option to go if you want to modify a workflow service with persisted workflows in WF 4. So, no dynamic updates, just version upgrades and smart routing.

MSDN documentation (link), samples (link), blog (link).

Explanation at StackOverflow (link). Screencasts (link).

System.ServiceModel.Routing - endpoint.tv episode (link).

An article from WWF Tutorial: Rules-Driven WCF Services (link) contains a C# sample WFRulesInWCF (link). More routing samples available in WF_WCF_Samples (see link below, in Links section).

Services

To test WF Services, use WCF Test Client.

Thing to note: Do not enclose string parameters in double quotes when using WCF Test Client.

It is very easy to publish a WF service. Main points are Send and Receive activities.

"CanCreateInstance" option on the Receive activity will create an instance of the workflow.

Receive Activity automatically creates a bookmark in the workflow. Later, after being persisted, a workflow can continue from a bookmark. When using persistence all this is handled transparently.

Reaching a Receive activity in a workflow will cause the workflow to become idle. If using persistence, the workflow can be persisted to the data store automatically. Once resumed, it will continue running from the bookmark after it receives the message it is waiting for.

"Visual Design of Workflows with WCF and WF 4" (link)

Correlation

Message-based correlation happens on the parameters passed in the call to the service method.

In order to use correlation, the correlation handle has to be initialized. It can be initialized explicitly, using Initialize Correlation activity, or it can be used through either Receive or Send activity, by using their Correlation Initialize property.

Message correlation article (link).

Workflow Insights: Correlation (link). Scheme (link).

What's a Correlation and why do I want to initialize it? (link)

Unit Testing Workflows

MSDN Magazine: Unit Testing Workflows and Activities (link).

Presentation on Unit Testing Workflows and Services from VS 2010 launch (link).

Unit testing at wwf.eu (link).

How to test WF4 workflows Microsoft.Activities.Simulation (link).

Links

Technology homepage (link) contains tutorials, guides, samples, news, etc.

WF 4 MSDN Page (link) includes samples, scenarios, and other documentation related to the library.

WF_WCF_Samples download page (link).

Forum (link).

WF on Codeplex (link). Additional Activity packs from Codeplex:

    • State Machine activity pack (link)
    • ADO.NET activity pack (link)

Articles

MSDN Magazine articles on the topic (link).

A Developer's Introduction to Windows Workflow Foundation (WF) in .NET 4 (link)

Versioning Workflows (link).

Articles and Overviews (link).

Blogs

    • Flow (link)
    • Matt W's Windows Workflows Place (link)

Episodes

EndPoint shows (link).

Introduction to Workflow in .NET 4 (link).

Lessons

Introduction to Workflow 4.0, at Channel 9 (link)

Wikis

WWF Wiki (ProblemSolver) - (link).

ASP.NET wiki - Workflow Foundation (link).

Activities

InvokeMethod

Invoking static methods - set TargetType to the type (class) and then, in the MethodName, set the static method name.

Invoking object methods - set the TargetObject to a variable name (defined previously) and in the MethodName set the name of the method to call on the object.