SqlWorkflowInstanceStore.InstanceLockedExceptionAction 属性

定义

指定在持久性提供程序捕获时 InstanceLockedException要执行的操作。

public:
 property System::Activities::DurableInstancing::InstanceLockedExceptionAction InstanceLockedExceptionAction { System::Activities::DurableInstancing::InstanceLockedExceptionAction get(); void set(System::Activities::DurableInstancing::InstanceLockedExceptionAction value); };
public System.Activities.DurableInstancing.InstanceLockedExceptionAction InstanceLockedExceptionAction { get; set; }
member this.InstanceLockedExceptionAction : System.Activities.DurableInstancing.InstanceLockedExceptionAction with get, set
Public Property InstanceLockedExceptionAction As InstanceLockedExceptionAction

属性值

持久性提供程序捕获某个项时要执行的操作 InstanceLockedException

示例

下面的代码示例演示如何在 .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();
}

注解

指定当工作流服务实例体验 InstanceLockedException某个工作流服务实例时应执行的操作。 当服务主机尝试锁定已由另一个所有者锁定的实例时,它会收到一个 InstanceLockedException 。 可能的值位于以下列表中:

  • 。 服务主机不会尝试锁定实例并将该实例传递给 InstanceLockedException 调用方。

  • BasicRetry。 服务主机重新尝试使用线性重试间隔锁定实例,并将异常传递给序列末尾的调用方。

  • AggressiveRetry。 服务主机重新尝试锁定实例,其延迟呈指数级增加,并在序列末尾传递给 InstanceLockedException 调用方。 间隔在开始时较短,尝试尽快获取锁,并且每次尝试失败时间隔都会变大。

适用于