mirror of https://github.com/dapr/docs.git
Merge branch 'v1.11' into issue_2766
This commit is contained in:
commit
d0f5705b89
|
@ -31,25 +31,27 @@ Dapr Workflow solves these complexities by allowing you to implement the task ch
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
// Expotential backoff retry policy that survives long outages
|
// Expotential backoff retry policy that survives long outages
|
||||||
var retryPolicy = TaskOptions.FromRetryPolicy(new RetryPolicy(
|
var retryOptions = new WorkflowTaskOptions
|
||||||
maxNumberOfAttempts: 10,
|
{
|
||||||
firstRetryInterval: TimeSpan.FromMinutes(1),
|
RetryPolicy = new WorkflowRetryPolicy(
|
||||||
backoffCoefficient: 2.0,
|
firstRetryInterval: TimeSpan.FromMinutes(1),
|
||||||
maxRetryInterval: TimeSpan.FromHours(1)));
|
backoffCoefficient: 2.0,
|
||||||
|
maxRetryInterval: TimeSpan.FromHours(1),
|
||||||
|
maxNumberOfAttempts: 10),
|
||||||
|
};
|
||||||
|
|
||||||
// Task failures are surfaced as ordinary .NET exceptions
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result1 = await context.CallActivityAsync<string>("Step1", wfInput, retryPolicy);
|
var result1 = await context.CallActivityAsync<string>("Step1", wfInput, retryOptions);
|
||||||
var result2 = await context.CallActivityAsync<byte[]>("Step2", result1, retryPolicy);
|
var result2 = await context.CallActivityAsync<byte[]>("Step2", result1, retryOptions);
|
||||||
var result3 = await context.CallActivityAsync<long[]>("Step3", result2, retryPolicy);
|
var result3 = await context.CallActivityAsync<long[]>("Step3", result2, retryOptions);
|
||||||
var result4 = await context.CallActivityAsync<Guid[]>("Step4", result3, retryPolicy);
|
var result4 = await context.CallActivityAsync<Guid[]>("Step4", result3, retryOptions);
|
||||||
return string.Join(", ", result4);
|
return string.Join(", ", result4);
|
||||||
}
|
}
|
||||||
catch (TaskFailedException)
|
catch (TaskFailedException) // Task failures are surfaced as TaskFailedException
|
||||||
{
|
{
|
||||||
// Retries expired - apply custom compensation logic
|
// Retries expired - apply custom compensation logic
|
||||||
await context.CallActivityAsync<long[]>("MyCompensation", options: retryPolicy);
|
await context.CallActivityAsync<long[]>("MyCompensation", options: retryOptions);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue