Ejemplo n.º 1
0
        private void TryInvokeFaultManager(TransportMessage message, Exception exception)
        {
            try
            {
                Exception e = exception;

                if (e is AggregateException)
                {
                    e = e.GetBaseException();
                }

                if (e is TransportMessageHandlingFailedException)
                {
                    e = e.InnerException;
                }

                message.RevertToOriginalBodyIfNeeded();

                failureManager.ProcessingAlwaysFailsForMessage(message, e);
            }
            catch (Exception ex)
            {
                Configure.Instance.RaiseCriticalError(String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);

                throw;
            }
        }
Ejemplo n.º 2
0
        private bool TryInvokeFaultManager(TransportMessage message, Exception exception)
        {
            try
            {
                Exception e = exception;

                if (e is AggregateException)
                {
                    e = e.GetBaseException();
                }

                if (e is TransportMessageHandlingFailedException)
                {
                    e = e.InnerException;
                }

                message.RevertToOriginalBodyIfNeeded();

                failureManager.ProcessingAlwaysFailsForMessage(message, e);

                return true;
            }
            catch (Exception ex)
            {
                Configure.Instance.RaiseCriticalError(
                    String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);
            }

            return false;
        }
Ejemplo n.º 3
0
        void TryInvokeFaultManager(TransportMessage message, Exception exception)
        {
            try
            {
                message.RevertToOriginalBodyIfNeeded();

                failureManager.ProcessingAlwaysFailsForMessage(message, exception);
            }
            catch (Exception ex)
            {
                criticalError.Raise(String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);

                throw;
            }
        }
Ejemplo n.º 4
0
        void TryInvokeFaultManager(TransportMessage message, Exception exception)
        {
            try
            {
                message.RevertToOriginalBodyIfNeeded();

                failureManager.ProcessingAlwaysFailsForMessage(message, exception);
            }
            catch (Exception ex)
            {
                criticalError.Raise(String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);

                throw;
            }
        }
Ejemplo n.º 5
0
        void TryInvokeFaultManager(TransportMessage message, Exception exception, int numberOfAttempts)
        {
            try
            {
                message.RevertToOriginalBodyIfNeeded();
                var numberOfRetries = numberOfAttempts - 1;
                message.Headers[Headers.FLRetries] = numberOfRetries.ToString();
                failureManager.ProcessingAlwaysFailsForMessage(message, exception);
            }
            catch (Exception ex)
            {
                criticalError.Raise(String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);

                throw;
            }
        }
Ejemplo n.º 6
0
        void TryInvokeFaultManager(TransportMessage message, Exception exception, int numberOfAttempts)
        {
            try
            {
                message.RevertToOriginalBodyIfNeeded();
                var numberOfRetries = numberOfAttempts - 1;
                message.Headers[Headers.FLRetries] = numberOfRetries.ToString();
                failureManager.ProcessingAlwaysFailsForMessage(message, exception);
            }
            catch (Exception ex)
            {
                criticalError.Raise(String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);

                throw;
            }
        }
Ejemplo n.º 7
0
        void ProcessMessage(TransportMessage message)
        {
            if (string.IsNullOrWhiteSpace(message.Id))
            {
                Logger.Error("Message without message id detected");

                FailureManager.SerializationFailedForMessage(message, new SerializationException("Message without message id received."));

                return;
            }

            var exceptionFromStartedMessageHandling = OnStartedMessageProcessing(message);

            if (TransactionSettings.IsTransactional)
            {
                if (firstLevelRetries.HasMaxRetriesForMessageBeenReached(message))
                {
                    OnFinishedMessageProcessing(message);
                    return;
                }
            }

            if (exceptionFromStartedMessageHandling != null)
                throw exceptionFromStartedMessageHandling; //cause rollback

            //care about failures here
            var exceptionFromMessageHandling = OnTransportMessageReceived(message);

            //and here
            var exceptionFromMessageModules = OnFinishedMessageProcessing(message);

            //but need to abort takes precedence - failures aren't counted here,
            //so messages aren't moved to the error queue.
            if (needToAbort)
            {
                return;
            }

            if (exceptionFromMessageHandling != null)
            {
                if (exceptionFromMessageHandling is AggregateException)
                {
                    var serializationException = exceptionFromMessageHandling.GetBaseException() as  SerializationException;
                    if (serializationException != null)
                    {
                        Logger.Error("Failed to serialize message with ID: " + message.Id, serializationException);

                        message.RevertToOriginalBodyIfNeeded();

                        FailureManager.SerializationFailedForMessage(message, serializationException);
                    }
                    else
                    {
                        throw exceptionFromMessageHandling;//cause rollback
                    }
                }
                else
                {
                    throw exceptionFromMessageHandling;//cause rollback
                }
            }

            if (exceptionFromMessageModules != null) //cause rollback
            {
                throw exceptionFromMessageModules;
            }
        }
Ejemplo n.º 8
0
        void ProcessMessage(TransportMessage message)
        {
            if (string.IsNullOrWhiteSpace(message.Id))
            {
                Logger.Error("Message without message id detected");

                FailureManager.SerializationFailedForMessage(message, new SerializationException("Message without message id received."));

                return;
            }

            var exceptionFromStartedMessageHandling = OnStartedMessageProcessing(message);

            if (TransactionSettings.IsTransactional)
            {
                if (firstLevelRetries.HasMaxRetriesForMessageBeenReached(message))
                {
                    OnFinishedMessageProcessing(message);
                    return;
                }
            }

            if (exceptionFromStartedMessageHandling != null)
            {
                throw exceptionFromStartedMessageHandling; //cause rollback
            }
            //care about failures here
            var exceptionFromMessageHandling = OnTransportMessageReceived(message);

            //and here
            var exceptionFromMessageModules = OnFinishedMessageProcessing(message);

            //but need to abort takes precedence - failures aren't counted here,
            //so messages aren't moved to the error queue.
            if (needToAbort)
            {
                return;
            }

            if (exceptionFromMessageHandling != null)
            {
                if (exceptionFromMessageHandling is AggregateException)
                {
                    var serializationException = exceptionFromMessageHandling.GetBaseException() as  SerializationException;
                    if (serializationException != null)
                    {
                        Logger.Error("Failed to serialize message with ID: " + message.Id, serializationException);

                        message.RevertToOriginalBodyIfNeeded();

                        FailureManager.SerializationFailedForMessage(message, serializationException);
                    }
                    else
                    {
                        throw exceptionFromMessageHandling;//cause rollback
                    }
                }
                else
                {
                    throw exceptionFromMessageHandling;//cause rollback
                }
            }

            if (exceptionFromMessageModules != null) //cause rollback
            {
                throw exceptionFromMessageModules;
            }
        }
Ejemplo n.º 9
0
        void ProcessMessage(TransportMessage message)
        {
            try
            {
                OnStartedMessageProcessing(message);
            }
            catch (Exception exception)
            {
                Logger.Error("Failed raising 'started message processing' event.", exception);
                if (ShouldExitBecauseOfRetries(message))
                {
                    return;
                }
                throw;
            }

            if (string.IsNullOrWhiteSpace(message.Id))
            {
                Logger.Error("Message without message id detected");

                FailureManager.SerializationFailedForMessage(message,
                    new SerializationException("Message without message id received."));

                return;
            }


            if (ShouldExitBecauseOfRetries(message))
            {
                try
                {
                    OnFinishedMessageProcessing(message);
                }
                catch (Exception exception)
                {
                    Logger.Error("Failed raising 'finished message processing' event.", exception);
                }
                return;
            }

            try
            {
                OnTransportMessageReceived(message);
            }
            catch (MessageDeserializationException serializationException)
            {
                Logger.Error("Failed to deserialize message with ID: " + message.Id, serializationException);

                message.RevertToOriginalBodyIfNeeded();

                FailureManager.SerializationFailedForMessage(message, serializationException);
            }
            catch (Exception)
            {
                //but need to abort takes precedence - failures aren't counted here,
                //so messages aren't moved to the error queue.
                if (!needToAbort)
                {
                    throw;
                }
            }
            finally
            {
                try
                {
                    OnFinishedMessageProcessing(message);
                }
                catch (Exception exception)
                {
                    Logger.Error("Failed raising 'finished message processing' event.", exception);
                    //but need to abort takes precedence - failures aren't counted here,
                    //so messages aren't moved to the error queue.
                    if (!needToAbort)
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        void ProcessMessage(TransportMessage message)
        {
            try
            {
                OnStartedMessageProcessing(message);
            }
            catch (Exception exception)
            {
                Logger.Error("Failed raising 'started message processing' event.", exception);
                if (ShouldExitBecauseOfRetries(message))
                {
                    return;
                }
                throw;
            }

            if (string.IsNullOrWhiteSpace(message.Id))
            {
                Logger.Error("Message without message id detected");

                FailureManager.SerializationFailedForMessage(message,
                                                             new SerializationException("Message without message id received."));

                return;
            }


            if (ShouldExitBecauseOfRetries(message))
            {
                try
                {
                    OnFinishedMessageProcessing(message);
                }
                catch (Exception exception)
                {
                    Logger.Error("Failed raising 'finished message processing' event.", exception);
                }
                return;
            }

            try
            {
                OnTransportMessageReceived(message);
            }
            catch (SerializationException serializationException)
            {
                Logger.Error("Failed to deserialize message with ID: " + message.Id, serializationException);

                message.RevertToOriginalBodyIfNeeded();

                FailureManager.SerializationFailedForMessage(message, serializationException);
            }
            catch (Exception)
            {
                //but need to abort takes precedence - failures aren't counted here,
                //so messages aren't moved to the error queue.
                if (!needToAbort)
                {
                    throw;
                }
            }
            finally
            {
                try
                {
                    OnFinishedMessageProcessing(message);
                }
                catch (Exception exception)
                {
                    Logger.Error("Failed raising 'finished message processing' event.", exception);
                    //but need to abort takes precedence - failures aren't counted here,
                    //so messages aren't moved to the error queue.
                    if (!needToAbort)
                    {
                        throw;
                    }
                }
            }
        }