Example #1
0
        /// <summary>
        /// Checks if there are any registered exceptions to the current message and
        /// if all of them are <see cref="FailFastException"/>, then mark the message
        /// as failed too many times.
        /// </summary>
        public async Task Process(IncomingStepContext context, Func <Task> next)
        {
            try
            {
                await next();

                var deadletterCommand = context.Load <ManualDeadletterCommand>();

                if (deadletterCommand != null)
                {
                    await ProcessDeadletterCommand(context, deadletterCommand);
                }
            }
            catch (Exception exception)
            {
                var transportMessage = context.Load <TransportMessage>();
                var messageId        = transportMessage.GetMessageId();
                if (_failFastChecker.ShouldFailFast(messageId, exception))
                {
                    // if we're currently executing a 2nd level retry, it's the 2nd level surrogate message ID we must mark as final
                    var messageIdToMarkAsFinal = context.Load <bool>(SimpleRetryStrategyStep.DispatchAsFailedMessageKey)
                        ? SimpleRetryStrategyStep.GetSecondLevelMessageId(messageId)
                        : messageId;

                    _errorTracker.MarkAsFinal(messageIdToMarkAsFinal);
                }
                throw;
            }
        }
Example #2
0
 /// <summary>
 /// Checks if there are any registered exceptions to the current message and
 /// if all of them are <see cref="FailFastException"/>, then mark the message
 /// as failed too many times.
 /// </summary>
 public async Task Process(IncomingStepContext context, Func <Task> next)
 {
     try
     {
         await next();
     }
     catch (Exception exception)
     {
         var transportMessage = context.Load <TransportMessage>();
         var messageId        = transportMessage.GetMessageId();
         if (_failFastChecker.ShouldFailFast(messageId, exception))
         {
             _errorTracker.MarkAsFinal(messageId);
         }
         throw;
     }
 }
Example #3
0
        public async Task Process(IncomingStepContext context, Func <Task> next)
        {
            var transportMessage = context.Load <TransportMessage>();
            var headers          = transportMessage.Headers;

            if (headers.TryGetValue(SecondLevelDispatchExceptionId, out var id))
            {
                if (!_exceptions.TryRemove(id, out var exception))
                {
                    throw new ArgumentException($"Could not find exception with ID {id}");
                }

                var messageId = headers.GetValue(Headers.MessageId);

                _errorTracker.RegisterError(messageId, exception);
                _errorTracker.MarkAsFinal(messageId);
            }

            await next();
        }
Example #4
0
        private void _checkFinal(string messageId, int?transportDeliveryCount, bool beforeTry)
        {
            var exceptions = _errorTracker.GetExceptions(messageId);

            // +1 as DeliveryCount is 1-based and is charged prior to 'receive'
            var deliveryCountFromExceptions = exceptions.Count() + 1;

            // if transport doesn't has deliveryCount, use the count of the Exceptions.
            var deliveryCount = (transportDeliveryCount ?? 0) > deliveryCountFromExceptions ? transportDeliveryCount : deliveryCountFromExceptions;

            if (beforeTry == true)
            {
                deliveryCount--;
            }

            if ((deliveryCount >= _arkRetryStrategySettings.MaxDeliveryAttempts &&
                 exceptions.Any()) || exceptions.Any(x => _failFastChecker.ShouldFailFast(messageId, x)))
            {
                _errorTracker.MarkAsFinal(messageId);
            }
        }
Example #5
0
        /// <summary>
        /// Checks if there are any registered exceptions to the current message and
        /// if all of them are <see cref="FailFastException"/>, then mark the message
        /// as failed too many times.
        /// </summary>
        public async Task Process(IncomingStepContext context, Func <Task> next)
        {
            try
            {
                await next();

                var deadletterCommand = context.Load <ManualDeadletterCommand>();

                if (deadletterCommand != null)
                {
                    await ProcessDeadletterCommand(context, deadletterCommand);
                }
            }
            catch (Exception exception)
            {
                var transportMessage = context.Load <TransportMessage>();
                var messageId        = transportMessage.GetMessageId();
                if (_failFastChecker.ShouldFailFast(messageId, exception))
                {
                    _errorTracker.MarkAsFinal(messageId);
                }
                throw;
            }
        }
 public void MarkAsFinal(string messageId)
 {
     _innerErrorTracker.MarkAsFinal(messageId);
 }