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で InstanceLockedExceptionAction を使用する方法を示します。

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 を渡します。 できるだけ早くロックを取得しようとして、間隔は最初に短く、失敗するたびに間隔が大きくなります。

適用対象