How to: Configure Persistence with WorkflowServiceHost

This article describes how to configure the SQL Workflow Instance Store feature to enable persistence for workflows hosted in WorkflowServiceHost by using a configuration file. Before using the SQL Workflow Instance Store feature, you must create a SQL database that's used to persist workflow instances. For more information, see How to: Enable SQL Persistence for Workflows and Workflow Services.

To Configure the SQL Workflow Instance Store in Configuration

  1. The properties of the SQL workflow instance store can be configured through the SqlWorkflowInstanceStoreBehavior, a service behavior that allows you to change the settings through XML configuration. The following configuration example shows how to configure the SQL workflow instance store by using the <sqlWorkflowInstanceStore> behavior element in a configuration file.

    <serviceBehaviors>
        <behavior name="">
            <sqlWorkflowInstanceStore
                 connectionString="...;Async=true"
                 instanceEncodingOption="GZip | None"
                 instanceCompletionAction="DeleteAll | DeleteNothing"
                 instanceLockedExceptionAction="NoRetry | SimpleRetry | AggressiveRetry"
                 hostLockRenewalPeriod="00:00:30"
                 runnableInstancesDetectionPeriod="00:00:05">
            </sqlWorkflowInstanceStore>
        </behavior>
    </serviceBehaviors>
    

    For more information about how to configure the SQL workflow instance store, see How to: Enable SQL Persistence for Workflows and Workflow Services. For more information about the individual settings for the <sqlWorkflowInstanceStore> behavior element, see SQL Workflow Instance Store.

    Note

    The preceding configuration example uses simplified configuration. For more information, see Simplified Configuration

To Configure the SQL Workflow Instance Store in Code

  1. The properties of the SQL workflow instance store can be configured through the SqlWorkflowInstanceStoreBehavior, a service behavior that allows you to change the settings through code. The following example shows how to configure the SQL workflow instance store by using the SqlWorkflowInstanceStoreBehavior behavior element in code.

    host.Description.Behaviors.Add(new SqlWorkflowInstanceStoreBehavior
    {
       ConnectionString = "...;Async=true",
       InstanceEncodingOption = "GZip | None",
       InstanceCompletionAction = "DeleteAll | DeleteNothing",
       InstanceLockedExceptionAction = "NoRetry | SimpleRetry | AggressiveRetry",
       HostLockRenewalPeriod = new TimeSpan(00, 00, 30),
       RunnableInstancesDetectionPeriod = new TimeSpan(00, 00, 05)
    });
    

    For more information about how to configure the SQL workflow instance store, see How to: Enable SQL Persistence for Workflows and Workflow Services. For more information about the individual settings for the SqlWorkflowInstanceStoreBehavior behavior element, see SQL Workflow Instance Store.

    Note

    The preceding configuration example uses simplified configuration. For more information, see Simplified Configuration

    For an example of how to configure persistence programmatically see How to: Enable Persistence for Workflows and Workflow Services.

See also