public IContinuation DetermineContinuation(Exception exception, HandlerChain handlerChain, HandlerGraph graph) { if (Envelope.Attempts >= handlerChain.MaximumAttempts) { return(new MoveToErrorQueue(exception)); } return(handlerChain.DetermineContinuation(Envelope, exception) ?? graph.DetermineContinuation(Envelope, exception) ?? new MoveToErrorQueue(exception)); }
private async Task moveToDelayedMessageQueue(Envelope envelope, EnvelopeContext context) { try { envelope.Attempts++; _delayedJobs.Enqueue(envelope.ExecutionTime.Value, envelope); await envelope.Callback.MarkSuccessful(); } catch (Exception e) { if (envelope.Attempts >= 3) { await envelope.Callback.MarkFailed(e); context.Logger.LogException(e, envelope.CorrelationId, "Failed to move delayed message to the delayed message queue"); } var continuation = _graph.DetermineContinuation(envelope, e) ?? new MoveToErrorQueue(e); await continuation.Execute(envelope, context, DateTime.UtcNow); } }