public void EventListenerSettingsAreProperlyAppliedToReplyListener(string queueName, string topics)
        {
            // Arrange
            string[] topicNames = topics.Split(",");

            MicroserviceListener listener = new MicroserviceListener {
                Queue = queueName, TopicExpressions = topicNames
            };

            MicroserviceReplayListener replayListener = new MicroserviceReplayListener();

            // Act
            replayListener.ApplyListenerSettings(listener);

            // Assert
            string[] expectedTopicNames = topicNames.Select(e => $"{ReplayTopicNames.ReplayEventTopicPrefix}{e}").ToArray();

            Assert.AreEqual($"{ReplayTopicNames.ReplayEventTopicPrefix}{queueName}", replayListener.Queue);
            CollectionAssert.AreEqual(expectedTopicNames, replayListener.TopicExpressions.ToArray());
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Apply the settings of a MicroserviceListener to a ReplayListener
 ///
 /// This allows us to keep the configuration of a replaylistener at 0 and just copy
 /// everything from an existing listener
 /// </summary>
 public void ApplyListenerSettings(MicroserviceListener listener)
 {
     Queue            = $"{ReplayTopicNames.ReplayEventTopicPrefix}{listener.Queue}";
     TopicExpressions = listener.TopicExpressions.Select(e => $"{ReplayTopicNames.ReplayEventTopicPrefix}{e}");
 }