本文整理汇总了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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
}
}