说我有以下消费者,其中有重试策略:
public class RetryOnlyFailedPartConsumer : IConsumer<Command>
{
public async Task Consume(ConsumeContext<Command> context)
{
await DoSomething();
await DoSomethingElse();
}
private async Task DoSomething()
{
// Some discrete piece of work
}
private async Task DoSomethingElse()
{
throw new Exception();
}
}
当发生异常时,我只想重试失败的部分,在这种情况下,DoSomethingElse()
,并跳过DoSomething()
,因为它成功阻止了多次执行。我该怎么办?