Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Rebus.Tests/Retry/Simple/TestDefaultRetryStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task CreatesInfoForSecondLevelRetryException(
Mock<IExceptionInfoFactory> exceptionInfoFactory,
IncomingStepContext context,
TransportMessage message, string id,
Exception[] nextExceptions)
Exception nextException)
{
failFastChecker.Setup(ffc => ffc.ShouldFailFast(It.IsAny<string>(), It.IsAny<Exception>())).Returns(false);
errorTracker.Setup(et => et.HasFailedTooManyTimes(It.IsAny<string>())).ReturnsAsync(true);
Expand All @@ -61,8 +61,8 @@ public async Task CreatesInfoForSecondLevelRetryException(
context.Save(message);

int i = 0;
await step.Process(context, () => throw nextExceptions[i++]);
await step.Process(context, () => throw nextException);

exceptionInfoFactory.Verify(eif => eif.CreateInfo(nextExceptions[1]));
exceptionInfoFactory.Verify(eif => eif.CreateInfo(nextException));
}
}
34 changes: 17 additions & 17 deletions Rebus/Retry/Simple/DefaultRetryStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ await PassToErrorHandler(context, _exceptionInfoFactory.CreateInfo(new RebusAppl
}
}

if (await _errorTracker.HasFailedTooManyTimes(messageId))
{
if (_retryStrategySettings.SecondLevelRetriesEnabled)
{
await DispatchSecondLevelRetry(transactionContext, messageId, context, next);
return;
}

var aggregateException = GetAggregateException(await _errorTracker.GetExceptions(messageId));

await PassToErrorHandler(context, aggregateException);
await _errorTracker.CleanUp(messageId);
transactionContext.SetResult(commit: false, ack: true);
return;
}

try
{
await next();
Expand Down Expand Up @@ -145,23 +161,7 @@ async Task HandleException(Exception exception, ITransactionContext transactionC

await _errorTracker.RegisterError(messageId, exception);

if (!await _errorTracker.HasFailedTooManyTimes(messageId))
{
transactionContext.SetResult(commit: false, ack: false);
return;
}

if (_retryStrategySettings.SecondLevelRetriesEnabled)
{
await DispatchSecondLevelRetry(transactionContext, messageId, context, next);
return;
}

var aggregateException = GetAggregateException(await _errorTracker.GetExceptions(messageId));

await PassToErrorHandler(context, aggregateException);
await _errorTracker.CleanUp(messageId);
transactionContext.SetResult(commit: false, ack: true);
transactionContext.SetResult(commit: false, ack: false);
}

async Task DispatchSecondLevelRetry(ITransactionContext transactionContext, string messageId, IncomingStepContext context, Func<Task> next)
Expand Down