public TopicHandlerBuilder(string topic, MessageBusSettings settings)
            : base(topic, typeof(TRequest), settings)
        {
            ConsumerSettings.ResponseType = typeof(TResponse);

            var consumerSettingsExist = settings.Consumers.Any(x => x.Topic == topic && x.ConsumerMode == ConsumerMode.RequestResponse);

            Assert.IsFalse(consumerSettingsExist,
                           () => new ConfigurationMessageBusException($"Attempted to configure request handler for topic '{topic}' when one was already configured. You can only have one request handler for a given topic, otherwise which response would you send back?"));
        }
Example #2
0
        public MessageBusBuilder MergeFrom(MessageBusSettings settings)
        {
            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            Settings.MergeFrom(settings);
            return(this);
        }
        public virtual void MergeFrom(MessageBusSettings settings)
        {
            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (settings.Producers.Count > 0)
            {
                foreach (var p in settings.Producers)
                {
                    Producers.Add(p);
                }
            }

            if (settings.Consumers.Count > 0)
            {
                foreach (var c in settings.Consumers)
                {
                    Consumers.Add(c);
                }
            }

            if (Serializer == null && settings.Serializer != null)
            {
                Serializer = settings.Serializer;
            }

            if (RequestResponse == null && settings.RequestResponse != null)
            {
                RequestResponse = settings.RequestResponse;
            }

            if (Serializer == null && settings.Serializer != null)
            {
                Serializer = settings.Serializer;
            }

            if (DependencyResolver == null && settings.DependencyResolver != null)
            {
                DependencyResolver = settings.DependencyResolver;
            }

            if (OnMessageExpired == null && settings.OnMessageExpired != null)
            {
                OnMessageExpired = settings.OnMessageExpired;
            }

            if (OnMessageFault == null && settings.OnMessageFault != null)
            {
                OnMessageFault = settings.OnMessageFault;
            }
        }
        protected AbstractTopicConsumerBuilder(string topic, Type messageType, MessageBusSettings settings)
        {
            Topic       = topic;
            MessageType = messageType;
            Settings    = settings ?? throw new ArgumentNullException(nameof(settings));

            ConsumerSettings = new ConsumerSettings
            {
                Topic       = topic,
                MessageType = messageType
            };
            Settings.Consumers.Add(ConsumerSettings);
        }
        protected AbstractTopicConsumerBuilder(string topic, Type messageType, MessageBusSettings settings)
        {
            Topic       = topic;
            MessageType = messageType;
            Settings    = settings;

            ConsumerSettings = new ConsumerSettings
            {
                Topic       = topic,
                MessageType = messageType
            };
            Settings.Consumers.Add(ConsumerSettings);
        }
        protected GroupConsumerBuilder(string group, string topic, MessageBusSettings settings)
        {
            Group = group;

            var consumerSettingsExist = settings.Consumers.Any(x => x.Group == group && x.Topic == topic);

            Assert.IsFalse(consumerSettingsExist,
                           () => new ConfigurationMessageBusException($"Group '{group}' configuration for topic '{topic}' already exists"));

            ConsumerSettings = new ConsumerSettings
            {
                Group       = group,
                Topic       = topic,
                MessageType = typeof(TMessage)
            };
            settings.Consumers.Add(ConsumerSettings);
        }
Example #7
0
 public TopicConsumerBuilder(string topic, Type messageType, MessageBusSettings settings)
     : base(topic, messageType, settings)
 {
 }
 public ConsumerBuilder(MessageBusSettings settings)
     : base(settings)
 {
 }
 public ConsumerBuilder(MessageBusSettings settings, Type messageType)
     : base(settings, messageType)
 {
 }
 protected AbstractConsumerBuilder(MessageBusSettings settings, Type messageType)
 {
     MessageType = messageType;
     Settings    = settings;
 }
 protected AbstractConsumerBuilder(MessageBusSettings settings)
     : this(settings, typeof(T))
 {
 }
Example #12
0
 public HandlerBuilder(MessageBusSettings settings)
     : base(settings)
 {
 }
 public GroupSubscriberBuilder(string group, string topic, MessageBusSettings settings)
     : base(group, topic, settings)
 {
 }
Example #14
0
 public SubscriberBuilder(MessageBusSettings settings)
     : base(settings)
 {
 }