Creating a Workflow Service
As
its name suggests, Windows Workflow Foundation (WF) lets developers create
workflow-based applications. WF workflows can be useful in a variety of
different situations. For example, WF can make it easier to create scalable applications
that pause, perhaps for a long time, while waiting for input. Whatever its
purpose, every WF workflow is built from activities, each of which performs
some function. An activity might do something simple, such as implement a While
statement, or carry out a more complex task, such as executing custom business
logic.
While
it’s certainly not required, a developer can use WF to create the logic for a
WCF service. Known as a workflow service, this technology combination often
makes sense. The developer builds scalable business logic as a WF workflow,
then lets that workflow’s activities interact with the outside world via WCF
services.
To
help do this, WF includes several activities specifically intended to allow WCF
communication. For example, the Send activity sends a message via WCF, while
the Receive activity receives a message. WCF 4 also allows correlation of
multiple requests sent to a particular workflow instance. For example, suppose
an instance of a workflow sends a request via WCF, then pauses waiting for a
message in response. While it’s waiting, this workflow instance will be
deactivated, with its state stored on disk. When a response message arrives,
WCF can determine from the message’s contents which workflow instance it’s
intended for—it can correlate this response message with the request message
sent earlier. The target workflow instance can then be reactivated and the
message delivered to the appropriate activity in that workflow.
Not
every WCF service should be built using WF. In a surprisingly large number of
cases, however, using WF and WCF together is the right choice. Workflow
services can be useful things.
No comments:
Post a Comment