PDC2008: Workflow Foundation 4

 

image 

 

By Serge Luca

MVP

image 

 

  1. New version of WF: WF4  
  2. WCF-WF integration
  3. Our workflows can run in the cloud 
  4. New host for WF (not just for WF) : Dublin (will ship just after VS2010)
  5. New language family: M
  6. Oslo : focused on Modeling (creation & storing)
  7. Office 14/Sharepointx will be based on WF 3.5
  8. What do you need to do next ?

1.New version of WF: WF4 

The Workflow Foundation team has recreated WF ; they started from the ground up !

What’s new in WF4 ?

  1. Activity
  2. Runtime
  3. Tools

1.Activity

 

  • Authoring is simpler and takes much less code
  • Fully declarative workflows and activities expressed in Xaml (Event handler, data management, expressions, rules…). Detail: .xoml files have been renamed .xaml…) ; to author the workflow or the activities code, we can :
  1. use the visual Designer
  2. directly write Xaml code
  3. use the Oslo M language combined with a xaml parser to generate Xaml code
  • Alignment across Expressions, Rules, and Activities
  • Seamless Composition Across Flow Styles
  • New paradigm after sequential Workflow and State machine workflow : the FlowChart (see Fig 1)

image

[Fig 1.Flow Chart activity, designer usability improved; from Kenny Wolf PDC2008 session]

  • An activity can have arguments (fig 2); arguments define the activity signature. Arguments have a type (any type), a name and a direction(in, out, in-out).Arguments are successors of dependency properties.

image 

[Fig 2.Activity arguments: here the WinPrize activity has 3 arguments; from Kenny Wolf PDC2008 session]

  • Activities can share data with other activities by using variables:

 

image

[ Fig 3.Variables available in the activity; from Matt Winkler PDC2008 session]

For instance, in fig 3, Generate Order activity can bind its arguments on Sequence and State Machine activity, and Send Report activity can bind its arguments on State Machine only.

In the next picture for instance we have 3 activities: Sequence, CollectVotes and AnalyzeVotes; CollectVotes has 3 arguments : Polling Place (In), ElectionDate (In) and Votes(Out); the AnalyzeVotes activity needs to get the Votes: to achieve this, we can define a Votes variables in Sequence and we can store de Out Votes arguments into the Votes variables; when Sequences closes we won’t need the variable anymore, and it’s not necessary to persist the data as we would have done in WF3.0/3.5.

 

image

[ Fig 4. Arguments and Variables;from Matt Winkler PDC2008 session]

  • The arguments and variables of the currently running activity define the active state of the workflow (and only this state will be persisted, not the whole workflow as before).
  • The activity state model has changed  :

 

  1. The activity state model is different (simpler, but compatible with the 3.0/3.5 activity model) (Fig 5): Initialized state, Compensating state seem to be gone.

              image[Fig 5. New simpler activity lifecycle; from Matt Winkler PDC2008 session]

  2. 4.0 activities are derived from a new class WorkflowElement:

     

    image

    [Fig 6. An activity is a WorkflowElement]

  3. System.WorkflowModel.WorkflowElement  can interact with the runtime (via the SystemWorkflowModel.ActivityExecution context)

  4. ->There are now 2 blocks of execution : Activities and WorkflowElements; we can schedule a WorkflowElement.

  5. We will be able to run 3.0/3.5 activities alongside 4.0 activities by using a new kid on the block, the Interop activity.
  6. Code activities are gone, the Initialize method is gone.
  7. WF 4 activities will run on the CLR 4.0
  8. The WorkflowInvoker.Invoke method allows you to run an activity directly (not through the workflow), which is great for unit testing.  
  9. 2.Runtime

     

    • 10-100X Performance Improvements :
    1. execution speed
    2. the persistence services doesn’t always persist the whole workflow anymore, but just the state of the running activity (the state is the variables + the arguments of the activity) –>more efficient
    3. activities can be multithreaded, the scheduler is still single threaded. We can now create scalable systems by using the APM (Asynchronous Programming Model): this is not recommended in WF 3.0/3.5 because we don’t have any guarantee that when the operation returns the worflow is still there; in WF 4.0 we can use the  SetupAsynchOperationBlock() method of theWorkflowExecutionContext class.Even if the asynch operation returns when the workflow is persisted, the workflow runtime is smart enough to rehydrate the workflow. Under the cover the asynchronous activity will leave the scheduler thread and will be replaced in the scheduler thread when to operation return. Same logic for real parallel activity.
    • Full control over persistence :
    1. we can persist the workflow without unloading it,…)
    2. we can define no persist zone (zone of the workflow where persistence will not occur, interesting in some asynchronous operations)
    3. persistence state can be schematized : we can store some variables in some specific places : for instance purchase orders can be stored in a specific table.
    • Flow-in Transactions : the workflow runtime knows when the host is running in a transaction and can transmit the transaction context to the activities; of course if the transaction is aborted the workflow state will be rolled back to its previous state.
    • Partial Trust Support (was full trust in WF 3/3.5)
    • Integrates with WCF, WPF, ASP.NET

    3.Tools

     

    • Designer Performance and Usability (fig 1). The designer is now based on WPF, but won’t be hosted in Silverlight in VS2010. This will probably be possible after VS2010…
    • Re-hosting Improvements ( 3 lines of code to rehost the WF designer in your application instead of several hours of coding in WF 30/3.5)
    • Unified Debugging Experience (we can step into expressions, rules, xaml based event handler… ).

 

2.WCF – WF Integration

  • Message Correlation (message related to each other and to the workflow instance, fig 7) :
    1. WF 3.0 : Channel (transient).
    2. WF 3.5 : WorkflowContext (based on cookie/soap) (improvement in WF 4.0 : it can work over one way messages.
    3. WF 4.0 : WorkflowContent : you can use your own value to specify the correlate messages and workflow instances. A Correlation Query allows to specify the value of the correlation and is used for inbound and outbound messages.  The workflow Dispatcher will retrieve the correlation value and associate the message with the workflow instance. The correlation value is associated with workflow in the Instance store; This correlation values provide a unified correlation mechanism across WF3.0-3.5-4.0

 

image[ Fig 7.Message Correlation]

  • Management Endpoint

WCF also provide a management endpoint to allow better workflow management (cancelling workflows, resuming workflows,…); this Management Endpoint is also used by Dublin.

image[ Fig 8.Management Endpoint]

3.Our workflows can run in the cloud 

  • The Windows cloud based operating system has been renamed "Windows Azure", and yes David Cutler, the hero of VMS and NT, is one of the main architect) .

    That is Workflow Services, a subsystem  of the new .Net services wich provides an workflow off premises host.

    The benefits of this off premises host are :

     

    • Reliability
    • Avalability :

      When you run your workflows in Azure .net Service, actually several instances of your workflow will run, duplicated in several nodes; if one node crashes, the system will use the instance running on another node.

    • Infrastructure maintained by Microsoft
    • Accessible from anywhere :

         We can access and manage our workflows from anywhere

     

    You can run the following existing WF 3/3.5 Out of the Box activities in Workflow Services

     

    • IfElse
    • Sequence
    • Suspend
    • Terminate
    • While

    (WF 4.0 supported in the future but not yet)

    And here are the existing Workflow Services activities :

     

    • CloudDelay
    • CloudHttpSend
    • CloudHttpReceive
    • CloudServiceBusSend
    • CloudXPathRead
    • CloudXPathUpdate

     image[Fig 9.Cloud Workflow activities]

  • Deployment and management:

     

    • Management portal (easy)
    • Management API to automate deployment

    To run on Azure, your workflows must be fully declarative, based on xaml, and this will much easier in the future with WF4; at the moment only some WF3.0/3.5 activities are currently supported and you still have to use Visual Studio 2008 + the .net service sdk.

    3.New host for WF (not just for WF) : Dublin (will ship just after VS2010)

    If you want to run your workflow on premises you can use your own workflow host or you can use a new one : Dublin.

     

    • Dublin is a special Kind of IIS WAS
    • Dublin is a kind of Biztalk light (now, I remember a chat with Paul Andrew, in Tech Ed 2007…)
    • Dublin doesn’t replace Biztalk (which is  a router between applications).

    Dublin is not the host for Windows Workflow services but the Dublin team and the Workflow Service team are mutually influencing each other and work under the same leadership.

    4.New language family: M

    5.Oslo : focused on Modeling (creation & storing)

    -an Oslo model can be defined by using a new DSL based on the M language: MSchema.
    Quadrant is a new tool that provides a common view of all models stored in an Oslo repository.
    -Quadrant will mostly be used by technical Analysts/architects.
    -Visual Studio will be used by developers.

    6.Office 14/Sharepointx will be based on WF 3.5

    Ok will be able to create real WF services in Sharepoint ( and make use of the famous Receive activity), but acording to Kenny Wowl Sharepoint/office 14 will first ship with WF 3.5 (it is currently based on WF 3.0) and will will have an upgrade to WF 4 later ; for more details, listen to what Kenny Wolf says here : PDC TL17 session after 37’45’’, and here PDC TL06 session after 68’48’’ ).
    I really hope that we will be able to use WF4 in Office14 Server…One of the reason is the following picture I got from the PDC (see the Sharepoint box in the picture below)

    image [Fig 10.The Activity Library and Sharepoint activities]

     

  • There are indeed a bunch of new Sharepoint activities in this pictures. I’ve verified this by analyzing some assemblies provided with Visual Studio 2010 September CTP (alpha code); Reflector showed me the following Sharepoint activities in System.WorkflowModel.Activities.dll [in the namespace System.WorkflowModel.Activities namespace:]

     

    • CreateSharepointListItem
    • DeleteSharepointListItem
    • GetSharepointListItems
    • SharepointConnectionContext
    • UpDateSharepointListItems

    These activities are classes derived from System.WorkflowModel.Activity which  is derived from WorkflowElement (also a new kid on the block…, see picture below). WorkflowElement is now in charge of the ActivityExecutionContext (communication with the runtime, including Transaction and identity).

     

    Picture1 

    [Fig 11.WorkflowElement, Activity, Sharepoint activities]

  • 7.What do you need to do next ?

    1. Read the Whitepaper “Workflow, Services, Models
    2. Watch the following sessions online:

       

    3. I will provide more details on WF4, WF services and Dublin in my blog (next days/weeks)
    4. If you are currently writing workflow code, please don’t use the Code activity anymore, but encapsulate your custom code in Custom activity with dependency properties: this will make your transition to WF4 much easier; this advice is also true for Sharepoint developers ! By the way, this was a PDC2005 good practice…

  • Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s