Exemplo n.º 1
0
        bool MessageWasSentFromSLR(TransportMessage message)
        {
            if (RetriesErrorQueue == null)
            {
                return(false);
            }

            // if the reply to address == ErrorQueue and RealErrorQueue is not null, the
            // SecondLevelRetries sat is running and the error happened within that sat.
            return(TransportMessageHelpers.GetAddressOfFaultingEndpoint(message) == RetriesErrorQueue);
        }
Exemplo n.º 2
0
        void SendFailureMessage(TransportMessage message, Exception e, bool serializationException = false)
        {
            SetExceptionHeaders(message, e);

            try
            {
                var destinationQ = RetriesErrorQueue ?? ErrorQueue;

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

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

                sender.Send(message, 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 has failed FLR and will be moved to the configured error q, ID={0}.", message.Id);
                }
                else
                {
                    var retryAttempt = TransportMessageHelpers.GetNumberOfRetries(message) + 1;

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

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

                throw new InvalidOperationException(errorMessage, exception);
            }
        }