當前位置: 首頁>>代碼示例>>C#>>正文


C# TransportMessage.RevertToOriginalBodyIfNeeded方法代碼示例

本文整理匯總了C#中NServiceBus.Unicast.Transport.TransportMessage.RevertToOriginalBodyIfNeeded方法的典型用法代碼示例。如果您正苦於以下問題:C# TransportMessage.RevertToOriginalBodyIfNeeded方法的具體用法?C# TransportMessage.RevertToOriginalBodyIfNeeded怎麽用?C# TransportMessage.RevertToOriginalBodyIfNeeded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NServiceBus.Unicast.Transport.TransportMessage的用法示例。


在下文中一共展示了TransportMessage.RevertToOriginalBodyIfNeeded方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TryInvokeFaultManager

        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;
        }
開發者ID:robert-hickey,項目名稱:NServiceBus,代碼行數:30,代碼來源:FirstLevelRetries.cs

示例2: TryInvokeFaultManager

        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;
            }
        }
開發者ID:ogdenmd,項目名稱:NServiceBus,代碼行數:15,代碼來源:FirstLevelRetries.cs

示例3: TryInvokeFaultManager

        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;
            }
        }
開發者ID:xqfgbc,項目名稱:NServiceBus,代碼行數:16,代碼來源:FirstLevelRetries.cs

示例4: ProcessMessage

        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;
            }
        }
開發者ID:strudel7,項目名稱:NServiceBus,代碼行數:67,代碼來源:TransportReceiver.cs

示例5: ProcessMessage

        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;
                    }
                }
            }
        }
開發者ID:xqfgbc,項目名稱:NServiceBus,代碼行數:79,代碼來源:TransportReceiver.cs


注:本文中的NServiceBus.Unicast.Transport.TransportMessage.RevertToOriginalBodyIfNeeded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。