private MessageFailureAction DefaultEvaluation(OnPipelineException pipelineEvent) { var transportMessage = pipelineEvent.GetTransportMessage(); var durationToIgnoreOnFailure = pipelineEvent.GetDurationToIgnoreOnFailure(); TimeSpan timeSpanToIgnoreRetriedMessage; var failureIndex = transportMessage.FailureMessages.Count + 1; var retry = failureIndex < pipelineEvent.GetMaximumFailureCount(); if (!retry || durationToIgnoreOnFailure == null || durationToIgnoreOnFailure.Length == 0) { timeSpanToIgnoreRetriedMessage = new TimeSpan(); } else { timeSpanToIgnoreRetriedMessage = durationToIgnoreOnFailure.Length < failureIndex ? durationToIgnoreOnFailure[durationToIgnoreOnFailure.Length - 1] : durationToIgnoreOnFailure[failureIndex - 1]; } return(new MessageFailureAction( retry, timeSpanToIgnoreRetriedMessage)); }
private MessageFailureAction DefaultEvaluation(OnPipelineException pipelineEvent) { var state = pipelineEvent.Pipeline.State; var transportMessage = state.GetTransportMessage(); var durationToIgnoreOnFailure = state.GetDurationToIgnoreOnFailure(); TimeSpan timeSpanToIgnoreRetriedMessage; var failureIndex = transportMessage.FailureMessages.Count + 1; var retry = failureIndex < state.GetMaximumFailureCount(); if (!retry || durationToIgnoreOnFailure == null || durationToIgnoreOnFailure.Length == 0) { timeSpanToIgnoreRetriedMessage = new TimeSpan(); } else { timeSpanToIgnoreRetriedMessage = durationToIgnoreOnFailure.Length < failureIndex ? durationToIgnoreOnFailure[durationToIgnoreOnFailure.Length - 1] : durationToIgnoreOnFailure[failureIndex - 1]; } return new MessageFailureAction( retry, timeSpanToIgnoreRetriedMessage); }
public void Execute(OnPipelineException pipelineEvent) { var state = pipelineEvent.Pipeline.State; _events.OnBeforePipelineExceptionHandled(this, new PipelineExceptionEventArgs(pipelineEvent.Pipeline)); try { if (pipelineEvent.Pipeline.ExceptionHandled) { return; } try { var receivedMessage = state.GetReceivedMessage(); var transportMessage = state.GetTransportMessage(); if (transportMessage == null) { if (receivedMessage != null) { state.GetWorkQueue().Release(receivedMessage.AcknowledgementToken); } return; } var action = _policy.EvaluateOutboxFailure(pipelineEvent); transportMessage.RegisterFailure(pipelineEvent.Pipeline.Exception.AllMessages(), action.TimeSpanToIgnoreRetriedMessage); if (action.Retry) { state.GetWorkQueue().Enqueue(transportMessage, _serializer.Serialize(transportMessage)); } else { state.GetErrorQueue().Enqueue(transportMessage, _serializer.Serialize(transportMessage)); } state.GetWorkQueue().Acknowledge(receivedMessage.AcknowledgementToken); } finally { pipelineEvent.Pipeline.MarkExceptionHandled(); _events.OnAfterPipelineExceptionHandled(this, new PipelineExceptionEventArgs(pipelineEvent.Pipeline)); } } finally { pipelineEvent.Pipeline.Abort(); } }
public void Execute(OnPipelineException pipelineEvent) { var state = pipelineEvent.Pipeline.State; var transportMessage = state.GetTransportMessage(); if (transportMessage == null) { return; } _endpointAggregator.MessageProcessingAborted(transportMessage.MessageId); }
public void Execute(OnPipelineException pipelineEvent) { Guard.AgainstNull(pipelineEvent, nameof(pipelineEvent)); _log.Error(pipelineEvent.Pipeline.Exception.AllMessages()); using (var stream = _serializer.Serialize(new Response { Exception = pipelineEvent.Pipeline.Exception.AllMessages() })) { _netMqRequestServer.SendFrameStream(stream); } pipelineEvent.Pipeline.MarkExceptionHandled(); }
public void Execute(OnPipelineException pipelineEvent) { var scope = pipelineEvent.GetTransactionScope(); if (scope == null) { return; } if (pipelineEvent.GetTransactionComplete()) { scope.Complete(); } scope.Dispose(); pipelineEvent.SetTransactionScope(null); }
public MessageFailureAction EvaluateMessageDistributionFailure(OnPipelineException pipelineEvent) { return DefaultEvaluation(pipelineEvent); }
public MessageFailureAction EvaluateOutboxFailure(OnPipelineException pipelineEvent) { return DefaultEvaluation(pipelineEvent); }
public void Execute(OnPipelineException pipelineEvent) { var state = pipelineEvent.Pipeline.State; _events.OnBeforePipelineExceptionHandled(this, new PipelineExceptionEventArgs(pipelineEvent.Pipeline)); try { if (pipelineEvent.Pipeline.ExceptionHandled) { return; } try { var transportMessage = state.GetTransportMessage(); var receivedMessage = state.GetReceivedMessage(); if (transportMessage == null) { if (receivedMessage != null) { state.GetWorkQueue().Release(receivedMessage.AcknowledgementToken); _log.Error(string.Format(Resources.ReceivePipelineExceptionMessageReleased, pipelineEvent.Pipeline.Exception.AllMessages())); } else { _log.Error(string.Format(Resources.ReceivePipelineExceptionMessageNotReceived, pipelineEvent.Pipeline.Exception.AllMessages())); } return; } var action = _policy.EvaluateMessageHandlingFailure(pipelineEvent); transportMessage.RegisterFailure(pipelineEvent.Pipeline.Exception.AllMessages(), action.TimeSpanToIgnoreRetriedMessage); using (var stream = _serializer.Serialize(transportMessage)) { var handler = state.GetMessageHandler(); var handlerFullTypeName = handler != null?handler.GetType().FullName : "(handler is null)"; var currentRetryCount = transportMessage.FailureMessages.Count; var retry = !(pipelineEvent.Pipeline.Exception is UnrecoverableHandlerException) && action.Retry; if (retry) { _log.Warning(string.Format(Resources.MessageHandlerExceptionWillRetry, handlerFullTypeName, pipelineEvent.Pipeline.Exception.AllMessages(), transportMessage.MessageType, transportMessage.MessageId, currentRetryCount, state.GetMaximumFailureCount())); state.GetWorkQueue().Enqueue(transportMessage, stream); } else { _log.Error(string.Format(Resources.MessageHandlerExceptionFailure, handlerFullTypeName, pipelineEvent.Pipeline.Exception.AllMessages(), transportMessage.MessageType, transportMessage.MessageId, state.GetMaximumFailureCount(), state.GetErrorQueue().Uri.Secured())); state.GetErrorQueue().Enqueue(transportMessage, stream); } } state.GetWorkQueue().Acknowledge(receivedMessage.AcknowledgementToken); } finally { pipelineEvent.Pipeline.MarkExceptionHandled(); _events.OnAfterPipelineExceptionHandled(this, new PipelineExceptionEventArgs(pipelineEvent.Pipeline)); } } finally { pipelineEvent.Pipeline.Abort(); } }
public MessageFailureAction EvaluateMessageHandlingFailure(OnPipelineException pipelineEvent) { return(DefaultEvaluation(pipelineEvent)); }