Пример #1
0
        /// <summary>
        /// Validate if all listeners are properly registered, if a listener
        /// is properly setup, copy its non-replay counterpart's settings over to the
        /// replay listener.
        /// </summary>
        protected virtual void ValidateReplayListeners()
        {
            if (EventListeners.Count != ReplayListeners.Count)
            {
                Logger.LogCritical("Amount of Event listeners is not equal to the amount of Replay listeners");

                throw new BusConfigurationException(
                          $"There are {EventListeners.Count} event listeners but {ReplayListeners.Count} replay listeners");
            }

            foreach (MicroserviceReplayListener listener in ReplayListeners)
            {
                MicroserviceListener normalListener = EventListeners.Find(e => listener.Queue == e.Queue);

                if (normalListener == null)
                {
                    Logger.LogCritical($"ReplayListener of {listener.Queue} has no non-replay counterpart.");
                    throw new BusConfigurationException($"ReplayListener of {listener.Queue} has no non-replay counterpart.");
                }

                Logger.LogDebug($"Applying configuration of listener for queue {listener.Queue} to replay listener");
                listener.ApplyListenerSettings(normalListener);
            }
        }