ערוך

שתף באמצעות


SqlWorkflowInstanceStore.RunnableInstancesDetectionPeriod Property

Definition

Specifies the time period after which the SQL Workflow Instance Store runs a detection task to detect any runnable or activatable workflow instances in the persistence database after the previous detection cycle.

public:
 property TimeSpan RunnableInstancesDetectionPeriod { TimeSpan get(); void set(TimeSpan value); };
public TimeSpan RunnableInstancesDetectionPeriod { get; set; }
member this.RunnableInstancesDetectionPeriod : TimeSpan with get, set
Public Property RunnableInstancesDetectionPeriod As TimeSpan

Property Value

Returns TimeSpan.

Examples

The following code sample demonstrates using RunnableInstancesDetectionPeriod in a SqlWorkflowInstanceStore.

static void Main(string[] args)
{
    // Create service host.
    WorkflowServiceHost host = new WorkflowServiceHost(new CountingWorkflow(), new Uri(hostBaseAddress));

    // Add service endpoint.
    host.AddServiceEndpoint("ICountingWorkflow", new BasicHttpBinding(), "");

    // Define SqlWorkflowInstanceStoreBehavior:
    //   Set interval to renew instance lock to 5 seconds.
    //   Set interval to check for runnable instances to 2 seconds.
    //   Instance Store does not keep instances after it is completed.
    //   Select exponential back-off algorithm when retrying to load a locked instance.
    //   Instance state information is compressed using the GZip compressing algorithm.
    SqlWorkflowInstanceStoreBehavior instanceStoreBehavior = new SqlWorkflowInstanceStoreBehavior(connectionString);
    instanceStoreBehavior.HostLockRenewalPeriod = new TimeSpan(0, 0, 5);
    instanceStoreBehavior.RunnableInstancesDetectionPeriod = new TimeSpan(0, 0, 2);
    instanceStoreBehavior.InstanceCompletionAction = InstanceCompletionAction.DeleteAll;
    instanceStoreBehavior.InstanceLockedExceptionAction = InstanceLockedExceptionAction.AggressiveRetry;
    instanceStoreBehavior.InstanceEncodingOption = InstanceEncodingOption.GZip;
    host.Description.Behaviors.Add(instanceStoreBehavior);

    // Open service host.
    host.Open();

    // Create a client that sends a message to create an instance of the workflow.
    ICountingWorkflow client = ChannelFactory<ICountingWorkflow>.CreateChannel(new BasicHttpBinding(), new EndpointAddress(hostBaseAddress));
    client.start();

    Console.WriteLine("(Press [Enter] at any time to terminate host)");
    Console.ReadLine();
    host.Close();
}

Remarks

The SqlWorkflowInstanceStore runs an internal task that periodically wakes up and checks if any runnable instances exist in the persistence database. An instance is runnable, if it is not in the suspended state or the completed state and satisfies the following conditions:

  • The instance is unlocked and has a pending timer that has expired.

  • The instance is unlocked and its status is Executing.

  • The instance has an expired lock on it.

The SQL Workflow Instance Store raises the HasRunnableWorkflowEvent when it finds a runnable instance in the database and also finds a workflow host capable of loading the instance running on the computer.

When a workflow host receives this event, it executes the TryLoadRunnableWorkflowCommand against the instance store to load the instance into the memory.

The type of the property is TimeSpan and the value is of the form "hh:mm:ss". The minimum value is "00:00:01" (1 sec). If omitted, defaults to "00:00:05" (5 secs). This parameter is an optional parameter.

Applies to