This topic has not yet been rated - Rate this topic

SqlWorkflowPersistenceService Class

Represents a persistence service that uses a SQL database to store workflow state information.

System.Object
  System.Workflow.Runtime.Hosting.WorkflowRuntimeService
    System.Workflow.Runtime.Hosting.WorkflowPersistenceService
      System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService

Namespace:  System.Workflow.Runtime.Hosting
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)
public class SqlWorkflowPersistenceService : WorkflowPersistenceService, 
	IPendingWork

The SqlWorkflowPersistenceService type exposes the following members.

  Name Description
Public method SqlWorkflowPersistenceService(NameValueCollection) Initializes a new instance of the SqlWorkflowPersistenceService class by using the specified parameters.
Public method SqlWorkflowPersistenceService(String) Initializes a new instance of the SqlWorkflowPersistenceService class by using the database connection string.
Public method SqlWorkflowPersistenceService(String, Boolean, TimeSpan, TimeSpan) Initializes a new instance of the SqlWorkflowPersistenceService class using a database connection string and other parameters.
Top
  Name Description
Public property EnableRetries Gets and sets a value that specifies whether the SqlWorkflowPersistenceService retries committing a work batch.
Public property LoadingInterval Gets the length of the loading interval.
Protected property Runtime Gets the WorkflowRuntime for this service. (Inherited from WorkflowRuntimeService.)
Public property ServiceInstanceId Gets the service instance identifier.
Protected property State Gets the state of the WorkflowRuntimeService. (Inherited from WorkflowRuntimeService.)
Top
  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetAllWorkflows Retrieves instance descriptions of all persisted workflows.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method LoadCompletedContextActivity Retrieves the specified completed scope from the database. (Overrides WorkflowPersistenceService.LoadCompletedContextActivity(Guid, Activity).)
Public method LoadExpiredTimerWorkflowIds Retrieves a list of ids for workflows with expired timers.
Protected method LoadWorkflowInstanceState Retrieves the specified workflow instance state from the database. (Overrides WorkflowPersistenceService.LoadWorkflowInstanceState(Guid).)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnStarted Starts a new timer and recovers running workflow instances. (Overrides WorkflowRuntimeService.OnStarted().)
Protected method OnStopped When overridden in a derived class, represents the method that will be called when the workflow runtime engine raises the WorkflowRuntime.Stopped event. (Inherited from WorkflowRuntimeService.)
Protected method RaiseServicesExceptionNotHandledEvent Raises the WorkflowRuntime.ServicesExceptionNotHandled event. (Inherited from WorkflowRuntimeService.)
Protected method SaveCompletedContextActivity Saves the state of the specified completed scope. (Overrides WorkflowPersistenceService.SaveCompletedContextActivity(Activity).)
Protected method SaveWorkflowInstanceState Saves the specified workflow instance state. (Overrides WorkflowPersistenceService.SaveWorkflowInstanceState(Activity, Boolean).)
Protected method Start Starts the SqlWorkflowPersistenceService. (Overrides WorkflowRuntimeService.Start().)
Protected method Stop Stops the service and the timer. (Overrides WorkflowRuntimeService.Stop().)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Protected method UnloadOnIdle Returns a value that indicates whether the workflow is unloaded when it is in an idle state. (Overrides WorkflowPersistenceService.UnloadOnIdle(Activity).)
Protected method UnlockWorkflowInstanceState Unlocks access to the specified workflow instance state. (Overrides WorkflowPersistenceService.UnlockWorkflowInstanceState(Activity).)
Top
  Name Description
Explicit interface implemetation Private method IPendingWork.Commit Writes an ICollection of serialized state objects to the database.
Explicit interface implemetation Private method IPendingWork.Complete Completes the work batch and releases any resources.
Explicit interface implemetation Private method IPendingWork.MustCommit Returns a value that indicates whether the collection of serialized state objects should be written to the database.
Top

The SqlWorkflowPersistenceService class represents a fully-functional persistence service. You can use this service out-of-box to persist and retrieve workflow state information about a workflow instance when requested to by the workflow runtime engine.

The SqlWorkflowPersistenceService participates in the workflow transaction batching functionality provided by the WorkflowCommitWorkBatchService. That is, it adds objects that represent pending writes to the SQL database to the WorkBatch and implements the IPendingWork interface.

The SqlWorkflowPersistenceService supports locking of workflow instances. This feature is used when several workflow runtimes share the same database. A column in the SQL database table is used to mark a workflow instance as locked whenever it is being used by a workflow runtime. The SqlWorkflowPersistenceService does not load a workflow instance that is marked as "in use" by another runtime. Typically these locks are released when the workflow instance is persisted, for example, on idle, completion, or termination. The locks can also be released automatically after a period of inactivity. This period of inactivity can be set using the constructor of the SqlWorkflowPersistenceService class. It can also be set through the configuration file.

For more information about persistence services in general, see the WorkflowPersistenceService class.

Workflow instances can contain timers, for example, if they have a DelayActivity. For workflows that contain timers, the SqlWorkflowPersistenceService records the time when the workflow's next timer expires. The SqlWorkflowPersistenceService periodically polls the database, looking for workflows whose timers have expired. The frequency of the polling interval can be set using the SqlWorkflowPersistenceService constructor or using a configuration file.

Note Note

When using both the SqlTrackingService and the SqlWorkflowPersistenceService in a workflow application, it is recommended to use a single database for both persistence and tracking.

.NET Framework

Supported in: 4, 3.5, 3.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ