I'm using the fan-out pattern to execute a list of tasks that have a possibility of failing. So I'm using the retry strategy to retry a couple times. Right now, if the SaveActivity fails after the last retry then it drops into the catch block and i loose the succeeded tasks.
Is there a way, I could filter out the tasks that have failed after the last try and then move on with the successful list?
Is it possible to get the retry attempt in the activity so that i could suppress the exception and flag the entity?
List<Task<AssetSyncResult>> tasks = modeList.
Select(r => context.CallActivityWithRetryAsync<AssetSyncResult>("SaveActivity", new RetryOptions(TimeSpan.FromSeconds(20),3), r)).
ToList();
try{
AssetSyncResult[] syncResults = await Task.WhenAll(tasks);
} catch(Exception e){
//rescue the workflow
}
Getting the results from the Task is a no go. After recovering from the exception thrown by Task.WhenAll the control never gets to filters that check the status of the Task. Here's how i've changed the code:
try
{
AssetSyncResult[] syncResults = await Task.WhenAll(tasks);
}
catch (System.Exception)
{
}
List<AssetSyncResult> resultsPassed = tasks.Where(r => r.IsCompleted).Select(r => r.Result).ToList();
List<AssetSyncResult> resultsFailed = tasks.Where(r => r.IsFaulted).Select(r => r.Result).ToList();