To track a StateMachine with WorkflowServices

Download Sample WF4 - Tracking State Machine Workflow Service
  1. Add a reference to Microsoft.Activities.Extensions see How do I install Microsoft.Activities.Extensions?
  2. Modify Web.config to add the behavior extensions and behaviors
<system.serviceModel>
  <extensions>
    <behaviorExtensions>
      <!-- Used for tracking StateMachines -->
      <add name="stateTracking" type="Microsoft.Activities.Extensions.ServiceModel.StateMachineTrackingElement, Microsoft.Activities.Extensions"/>
      <!-- Output tracking to VS Debug Window -->
      <add name="workflowServiceTrace" type="Microsoft.Activities.Extensions.Diagnostics.WorkflowServiceTraceElement, Microsoft.Activities.Extensions" />       
    </behaviorExtensions>
  </extensions>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
        <serviceMetadata httpGetEnabled="true"/>
        <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
        <serviceDebug includeExceptionDetailInFaults="false"/>
        <!-- Enable persistence -->
        <sqlWorkflowInstanceStore connectionString="Data Source=.\SQLExpress;Initial Catalog=SampleInstanceStore;Integrated Security=True;Asynchronous Processing=True"/>
        <!-- Enable tracking of state machines -->
        <stateTracking />
        <!-- Output tracking to VS Debug Window -->
        <workflowServiceTrace />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

Last edited Apr 9, 2012 at 7:43 PM by ronjacobs, version 2

Comments

EyadAB May 13, 2012 at 2:49 PM 
Hi,
just I wanted to point out that it takes 1 minute to see the state change and that becuase of the workflowIdle timeToPersist default(1 minute)
by adding this configuation <workflowIdle timeToPersist="00:00:01"/>
you'll see the changes very quickly after 1 second.