Thursday, June 11, 2009

Windows Workflow Foundation

Introduction:

It is a set of actions that is executed asynchronously by the engine provided by Windows WF. WFs are basically a set of activities. Activity is a step in workflow and is the unit of execution

One of the most interesting aspects of Windows Workflow Foundation (WF) is the separation between business process code and the actual implementation, often a requirement in Service Oriented Architecture (SOA). Before Windows Workflow Foundation the typical scenario would be to write both the business logic and the actual implementation in C#, Visual Basic .NET or another .NET language. The result was no clear separation between business logic and its implementation. With the release of Windows Workflow Foundation (WF) the business logic can be defined in the workflow while the actual underlying implementation is done in C#, Visual Basic .NET or another .NET language. So basically the what is done in the workflow and the how is done in traditional programming code.

Windows Workflow Foundation is basically a library consisting of an execution engine, a rules engine, a number of activities, a number of supporting runtime services and a designer allowing developers to design their workflows graphical in Visual Studio 2005 (VS2005). Since Windows Workflow Foundation is a library, not a standalone platform or service, the developer is completely free to include the Windows Workflow Foundation library in process in his own application or web site/service.

Base Components/Architecture:

• Host Process: Responsible for providing various runtime services to the workflow runtime engine.
• Runtime Engine: Responsible for workflow execution and state management
• Runtime Services: Provides additional functionality to the runtime engine.
• Base Activity Library: Set of general purpose activities for defining workflows.
• Visual Designer: Graphical and code-based construction

Hosting Model:

The WF runtime can be hosted in any .NET process
1) ASP.NET ( IIS ),
2) Windows Service,
3) Console applications,
4) Windows Forms applications,
5) Web Services ( IIS ).

Types of Workflow:

There are two main kinds of workflows:

1. Sequential (Sequential structure prescribes processing order): Its actions are executed in some predefined order with a beginning and an end. Examples of sequential workflows may include installations.

When to use Sequential Workflow:

-> The Workflow model can be express as a sequence of activities
-> The Workflow is in control of sequence of activities
-> The Workflow of its nature, encodes all the possible sequences of behavior in its structure
-> It is self driven

2. State machines (External events drive processing order): These workflows don't have a path, but it's represented as a set of states and transitions between states. Examples are a web shop: you may need approval for mailing, the user could pay via credit card or with a cheque, and each user is in one state and may go to any order depending on previous questions.

When to use State Machine Workflow:

-> The Workflow model does not have a defined path of execution
-> It may not be possible to model all the paths using a sequential workflow
-> The sequence of events is unpredictable
-> The Workflow to model is driven by external events

Few important terminology:

-> Activities: Windows Workflow Foundation provides a number of activities that you can use to send e-mail, handle errors, run code, or execute other tasks

-> Activity Framework: The activity framework provides a range of common functions used by many activities, such as validation, fault handling, and compilation

-> Workflow Runtime: The workflow runtime is the component that executes workflow instances with a host application

-> Persistence Service: Persistence services can be used to save a workflow instance to a data store if a workflow contains a long-running process

-> Transaction Service: We can use transaction services to ensure your data consistency in the event of communication or other failure

-> Tracking Service: Tracking services can be used to record which activities will execute in each workflow instance. They can also record when each activity executes. Use tracking services to troubleshoot or debug workflows

-> Scheduling Service: Scheduling services can be used to control how a workflow runtime creates threads for the instances of your workflow

0 comments: