SqlWorkflowInstanceStore.InstanceLockedExceptionAction Propriété

Définition

Spécifie l'action à entreprendre lorsque le fournisseur de persistance intercepte une exception 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

Valeur de propriété

Action à prendre lorsque le fournisseur de persistance intercepte une exception InstanceLockedException.

Exemples

L'exemple de code suivant montre comment utiliser InstanceLockedExceptionAction dans un 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();
}

Remarques

Spécifie quelle mesure un hôte de service doit prendre lorsqu'une instance de service du flux de travail rencontre une exception InstanceLockedException. L'hôte de service reçoit une exception InstanceLockedException lorsqu'il essaie de verrouiller une instance qui est déjà verrouillée par un autre propriétaire. Les valeurs possibles sont les suivantes :

  • Aucun. L'hôte de service n'essaie pas de verrouiller l'instance et passe l'objet InstanceLockedException à l'appelant.

  • BasicRetry. L'hôte de service réessaie de verrouiller l'instance avec un intervalle de tentative linéaire et passe l'exception à l'appelant à la fin de la séquence.

  • AggressiveRetry. L'hôte de service réessaie de verrouiller l'instance avec un délai exponentiellement croissant et passe l'objet InstanceLockedException à l'appelant à la fin de la séquence. Au départ, les intervalles sont courts dans le but d'acquérir le verrou le plus rapidement possible ; ils s'allongent ensuite à chaque tentative infructueuse.

S’applique à