Example #1
0
        async Task DispatchWithTrackerIdentifier(Func <Task> next, string identifierToTrackMessageBy, ITransactionContext transactionContext, string messageId, string secondLevelMessageId = null)
        {
            try
            {
                await next();

                await transactionContext.Commit();

                _errorTracker.CleanUp(messageId);

                if (secondLevelMessageId != null)
                {
                    _errorTracker.CleanUp(secondLevelMessageId);
                }
            }
            catch (OperationCanceledException) when(_cancellationToken.IsCancellationRequested)
            {
                // we're exiting, so we abort like this:
                _logger.Info("Dispatch of message with ID {messageId} was cancelled", messageId);

                transactionContext.Abort();
            }
            catch (Exception exception)
            {
                _errorTracker.RegisterError(identifierToTrackMessageBy, exception);

                transactionContext.Abort();
            }
        }
        async Task DispatchWithTrackerIdentifier(Func <Task> next, string identifierToTrackMessageBy, ITransactionContext transactionContext)
        {
            try
            {
                await next();
            }
            catch (Exception exception)
            {
                _errorTracker.RegisterError(identifierToTrackMessageBy, exception);

                transactionContext.Abort();
            }
        }
Example #3
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().ConfigureAwait(false);
     }
     catch (Exception exception)
     {
         var transportMessage = context.Load <TransportMessage>();
         var messageId        = transportMessage.GetMessageId();
         if (_failFastChecker.ShouldFailFast(messageId, exception))
         {
             _errorTracker.RegisterError(messageId, exception, final: true);
         }
         throw;
     }
 }
Example #4
0
        async Task DispatchWithTrackerIdentifier(Func <Task> next, string identifierToTrackMessageBy, ITransactionContext transactionContext, string[] identifiersToClearOnSuccess)
        {
            try
            {
                await next();

                await transactionContext.Commit();

                foreach (var id in identifiersToClearOnSuccess)
                {
                    _errorTracker.CleanUp(id);
                }
            }
            catch (Exception exception)
            {
                _errorTracker.RegisterError(identifierToTrackMessageBy, exception);

                transactionContext.Abort();
            }
        }
Example #5
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();
        }
        async Task DispatchWithTrackerIdentifier(Func <Task> next, string identifierToTrackMessageBy, ITransactionContext transactionContext, string messageId, string secondLevelMessageId = null)
        {
            try
            {
                await next().ConfigureAwait(false);

                await transactionContext.Commit().ConfigureAwait(false);

                _errorTracker.CleanUp(messageId);

                if (secondLevelMessageId != null)
                {
                    _errorTracker.CleanUp(secondLevelMessageId);
                }
            }
            catch (Exception exception)
            {
                _errorTracker.RegisterError(identifierToTrackMessageBy, exception);

                transactionContext.Abort();
            }
        }