/// <summary>
        /// Sends to subscriber.
        /// </summary>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="envelope">The envelope.</param>
        /// <param name="session">The session.</param>
        protected void SendToSubscriber(IMessageSubscriber subscriber, IMessageEnvelope envelope, ISessionContext session)
        {
            bool retry      = true;
            int  retryCount = 0;

            while (retry)
            {
                retryCount++;
                try
                {
                    InvokeOnMessage(subscriber, envelope, retryCount, session);
                    retry = false;
                    logger.LogSubscribeSuccess(envelope, string.Format(CultureInfo.CurrentCulture, "Subscriber {0} successfully processed message {1} (UID: {2}",
                                                                       subscriber.GetType().FullName, envelope.Message.GetType().FullName, envelope.MessageUID), subscriber.GetType());
                }
                catch (Exception.MessagingException messagingEx)
                {
                    logger.LogSubscribeFailure(envelope, messagingEx.Message, messagingEx, subscriber.GetType());
                    retry = messagingEx.Retry;
                    if (retry)
                    {
                        TimeSpan sleepTime = TimeSpan.FromMinutes(MaxWaitInMinutes);

                        if (messagingEx.RetryInterval.Minutes < sleepTime.Minutes)
                        {
                            sleepTime = messagingEx.RetryInterval;
                        }

                        Thread.Sleep(sleepTime.Milliseconds);
                    }
                }
                catch (System.Exception exception)
                {
                    logger.LogSubscribeFailure(envelope, exception.Message, exception, subscriber.GetType());
                    retry = false;
                }
                if (retryCount >= MaxRetries)
                {
                    retry = false;
                }
            }
        }