void SendFailureMessage(TransportMessage message, Exception e, string reason)
        {
            if (errorQueue == null)
            {
                Logger.Error("Message processing always fails for message with ID " + message.Id + ".", e);
                return;
            }

            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress, reason);

            try
            {
                messageSender.Send(message, new SendOptions(errorQueue));
            }
            catch (Exception exception)
            {
                var    queueNotFoundException = exception as QueueNotFoundException;
                string errorMessage;

                if (queueNotFoundException != null)
                {
                    errorMessage = string.Format("Could not forward failed message to error queue '{0}' as it could not be found.", queueNotFoundException.Queue);
                    Logger.Fatal(errorMessage);
                }
                else
                {
                    errorMessage = "Could not forward failed message to error queue.";
                    Logger.Fatal(errorMessage, exception);
                }

                throw new InvalidOperationException(errorMessage, exception);
            }
        }
        void SendFailureMessage(TransportMessage message, Exception e, string reason)
        {
            if (errorQueue == null)
            {
                Logger.Error("Message processing always fails for message with ID " + message.Id + ".", e);
                return;
            }

            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress,reason);
            
            try
            {
                messageSender.Send(message, new SendOptions(errorQueue));
            }
            catch (Exception exception)
            {
                var queueNotFoundException = exception as QueueNotFoundException;
                string errorMessage;

                if (queueNotFoundException != null)
                {
                    errorMessage = string.Format("Could not forward failed message to error queue '{0}' as it could not be found.", queueNotFoundException.Queue);
                    Logger.Fatal(errorMessage);
                }
                else
                {
                    errorMessage = "Could not forward failed message to error queue.";
                    Logger.Fatal(errorMessage, exception);
                }

                throw new InvalidOperationException(errorMessage, exception);
            }
        }
Пример #3
0
        void HandleProcessingAlwaysFailsForMessage(TransportMessage message, Exception e, int numberOfRetries)
        {
            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);

            if (MessageWasSentFromSLR(message))
            {
                SendToErrorQueue(message, e);
                return;
            }

            var flrPart = numberOfRetries > 0
                ? $"Message with '{message.Id}' id has failed FLR and"
                : $"FLR is disabled and the message '{message.Id}'";

            //HACK: We need this hack here till we refactor the SLR to be a first class concept in the TransportReceiver
            if (RetriesQueue == null)
            {
                Logger.ErrorFormat("{0} will be moved to the configured error queue.", flrPart);
                SendToErrorQueue(message, e);
                return;
            }

            var defer = SecondLevelRetriesConfiguration.RetryPolicy.Invoke(message);

            if (defer < TimeSpan.Zero)
            {
                Logger.ErrorFormat(
                    "SLR has failed to resolve the issue with message {0} and will be forwarded to the error queue at {1}",
                    message.Id, ErrorQueue);
                SendToErrorQueue(message, e);
                return;
            }

            SendToRetriesQueue(message, e, flrPart);
        }
Пример #4
0
        void HandleProcessingAlwaysFailsForMessage(TransportMessage message, Exception e, int numberOfRetries)
        {
            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);

            if (MessageWasSentFromSLR(message))
            {
                SendToErrorQueue(message, e);
                return;
            }

            var flrPart = numberOfRetries > 0
                ? $"Message with '{message.Id}' id has failed FLR and"
                : $"FLR is disabled and the message '{message.Id}'";

            //HACK: We need this hack here till we refactor the SLR to be a first class concept in the TransportReceiver
            if (RetriesQueue == null)
            {
                Logger.ErrorFormat("{0} will be moved to the configured error queue.", flrPart);
                SendToErrorQueue(message, e);
                return;
            }

            var defer = SecondLevelRetriesConfiguration.RetryPolicy.Invoke(message);

            if (defer < TimeSpan.Zero)
            {
                Logger.ErrorFormat(
                    "SLR has failed to resolve the issue with message {0} and will be forwarded to the error queue at {1}",
                    message.Id, ErrorQueue);
                SendToErrorQueue(message, e);
                return;
            }

            SendToRetriesQueue(message, e, flrPart);
        }
Пример #5
0
        void SendFailureMessage(TransportMessage message, Exception e, bool serializationException = false)
        {
            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);

            try
            {
                var destinationQ = RetriesErrorQueue ?? ErrorQueue;

                // Intentionally service-locate ISendMessages to avoid circular
                // resolution problem in the container
                var sender = builder.Build <ISendMessages>();

                if (serializationException || MessageWasSentFromSLR(message))
                {
                    sender.Send(message, new SendOptions(ErrorQueue));
                    return;
                }

                sender.Send(message, new SendOptions(destinationQ));

                //HACK: We need this hack here till we refactor the SLR to be a first class concept in the TransportReceiver
                if (RetriesErrorQueue == null)
                {
                    Logger.ErrorFormat("Message with '{0}' id has failed FLR and will be moved to the configured error queue.", message.Id);
                }
                else
                {
                    var retryAttempt = TransportMessageHeaderHelper.GetNumberOfRetries(message) + 1;

                    Logger.WarnFormat("Message with '{0}' id has failed FLR and will be handed over to SLR for retry attempt {1}.", message.Id, retryAttempt);
                }
            }
            catch (Exception exception)
            {
                var    queueNotFoundException = exception as QueueNotFoundException;
                string errorMessage;

                if (queueNotFoundException != null)
                {
                    errorMessage = string.Format("Could not forward failed message to error queue '{0}' as it could not be found.", queueNotFoundException.Queue);
                    Logger.Fatal(errorMessage);
                }
                else
                {
                    errorMessage = "Could not forward failed message to error queue.";
                    Logger.Fatal(errorMessage, exception);
                }

                throw new InvalidOperationException(errorMessage, exception);
            }
        }
Пример #6
0
        void SendFailureMessage(TransportMessage message, Exception e, bool serializationException = false)
        {
            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);

            try
            {
                var destinationQ = RetriesErrorQueue ?? ErrorQueue;
               
                // Intentionally service-locate ISendMessages to avoid circular
                // resolution problem in the container
                var sender = builder.Build<ISendMessages>();

                if (serializationException || MessageWasSentFromSLR(message))
                {
                    sender.Send(message, new SendOptions(ErrorQueue));
                    return;
                }

                sender.Send(message, new SendOptions(destinationQ));

                //HACK: We need this hack here till we refactor the SLR to be a first class concept in the TransportReceiver
                if (RetriesErrorQueue == null)
                {
                    Logger.ErrorFormat("Message with '{0}' id has failed FLR and will be moved to the configured error queue.", message.Id);
                }
                else
                {
                    var retryAttempt = TransportMessageHeaderHelper.GetNumberOfRetries(message) + 1;

                    Logger.WarnFormat("Message with '{0}' id has failed FLR and will be handed over to SLR for retry attempt {1}.", message.Id, retryAttempt);
                }
            }
            catch (Exception exception)
            {
                var queueNotFoundException = exception as QueueNotFoundException;
                string errorMessage;

                if (queueNotFoundException != null)
                {
                    errorMessage = string.Format("Could not forward failed message to error queue '{0}' as it could not be found.", queueNotFoundException.Queue);
                    Logger.Fatal(errorMessage);
                }
                else
                {
                    errorMessage = "Could not forward failed message to error queue.";
                    Logger.Fatal(errorMessage, exception);
                }

                throw new InvalidOperationException(errorMessage, exception);
            }
        }
Пример #7
0
        void HandleProcessingAlwaysFailsForMessage(TransportMessage message, Exception e, int numberOfRetries)
        {
            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);

            if (MessageWasSentFromSLR(message))
            {
                sender.Send(message, new SendOptions(ErrorQueue));
                busNotifications.Errors.InvokeMessageHasBeenSentToErrorQueue(message, e);
                return;
            }

            var flrPart = numberOfRetries > 0
                ? string.Format("Message with '{0}' id has failed FLR and", message.Id)
                : string.Format("FLR is disabled and the message '{0}'", message.Id);

            //HACK: We need this hack here till we refactor the SLR to be a first class concept in the TransportReceiver
            if (RetriesErrorQueue == null)
            {
                sender.Send(message, new SendOptions(ErrorQueue));
                Logger.ErrorFormat("{0} will be moved to the configured error queue.", flrPart);
                busNotifications.Errors.InvokeMessageHasBeenSentToErrorQueue(message, e);
                return;
            }

            var defer = SecondLevelRetriesConfiguration.RetryPolicy.Invoke(message);

            if (defer < TimeSpan.Zero)
            {
                SendToErrorQueue(message, e);
                return;
            }
            sender.Send(message, new SendOptions(RetriesErrorQueue));

            var retryAttempt = TransportMessageHeaderHelper.GetNumberOfRetries(message) + 1;

            Logger.WarnFormat("{0} will be handed over to SLR for retry attempt {1}.", flrPart, retryAttempt);
            busNotifications.Errors.InvokeMessageHasBeenSentToSecondLevelRetries(retryAttempt, message, e);
        }
Пример #8
0
        void HandleProcessingAlwaysFailsForMessage(TransportMessage message, Exception e, int numberOfRetries)
        {
            message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);

            if (MessageWasSentFromSLR(message))
            {
                sender.Send(message, new SendOptions(ErrorQueue));
                busNotifications.Errors.InvokeMessageHasBeenSentToErrorQueue(message, e);
                return;
            }

            var flrPart = numberOfRetries > 0
                ? string.Format("Message with '{0}' id has failed FLR and", message.Id)
                : string.Format("FLR is disabled and the message '{0}'", message.Id);

            //HACK: We need this hack here till we refactor the SLR to be a first class concept in the TransportReceiver
            if (RetriesErrorQueue == null)
            {
                sender.Send(message, new SendOptions(ErrorQueue));
                Logger.ErrorFormat("{0} will be moved to the configured error queue.", flrPart);
                busNotifications.Errors.InvokeMessageHasBeenSentToErrorQueue(message, e);
                return;
            }

            var defer = SecondLevelRetriesConfiguration.RetryPolicy.Invoke(message);

            if (defer < TimeSpan.Zero)
            {
                SendToErrorQueue(message, e);
                return;
            }
            sender.Send(message, new SendOptions(RetriesErrorQueue));

            var retryAttempt = TransportMessageHeaderHelper.GetNumberOfRetries(message) + 1;

            Logger.WarnFormat("{0} will be handed over to SLR for retry attempt {1}.", flrPart, retryAttempt);
            busNotifications.Errors.InvokeMessageHasBeenSentToSecondLevelRetries(retryAttempt, message, e);
        }
Пример #9
0
 void HandleSerializationFailedForMessage(TransportMessage message, Exception e)
 {
     message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);
     SendToErrorQueue(message, e);
 }
Пример #10
0
 void HandleSerializationFailedForMessage(TransportMessage message, Exception e)
 {
     message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);
     SendToErrorQueue(message, e);
 }
Пример #11
0
 void HandleSerializationFailedForMessage(TransportMessage message, Exception e)
 {
     message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);
     sender.Send(message, new SendOptions(ErrorQueue));
 }
Пример #12
0
 void HandleSerializationFailedForMessage(TransportMessage message, Exception e)
 {
     message.SetExceptionHeaders(e, localAddress ?? config.LocalAddress);
     sender.Send(message, new SendOptions(ErrorQueue));
 }