SqlWorkflowInstanceStore.InstanceLockedExceptionAction Proprietà

Definizione

Specifica l'azione da eseguire quando il provider di persistenza intercetta un oggetto 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

Valore della proprietà

Azione da eseguire quando il provider di persistenza intercetta un oggetto InstanceLockedException.

Esempio

Nell'esempio di codice seguente viene mostrato l'utilizzo di InstanceLockedExceptionAction in 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();
}

Commenti

Specificare quale azione deve essere eseguita da un host del servizio quando per un'istanza del servizio del flusso di lavoro viene generato un oggetto InstanceLockedException. L'host del servizio riceve un oggetto InstanceLockedException quando tenta di bloccare un'istanza che è già bloccata da un altro proprietario. Nell'elenco seguente sono indicati i valori possibili:

  • Nessuno. L'host del servizio non tenta di bloccare l'istanza e passa InstanceLockedException al chiamante.

  • BasicRetry. L'host del servizio tenta di nuovo di bloccare l'istanza con un intervallo tra tentativi lineare e passa l'eccezione al chiamante alla fine della sequenza.

  • AggressiveRetry. L'host del servizio tenta di nuovo di bloccare l'istanza con un ritardo che aumenta in modo esponenziale e passa InstanceLockedException al chiamante alla fine della sequenza. Gli intervalli sono brevi all'inizio, nel tentativo di acquisire il blocco il più rapidamente possibile, e diventano più lunghi a ogni tentativo non riuscito.

Si applica a