Esempio n. 1
0
        public void QueueBindMessage <T>(string queueName, string exchange, string routingKey = "", bool hierarchy = false, IEnumerable <BusHeader> filter = null)
        {
            var helper = new SubscriptionHelper((type, filterInfo, handler) =>
            {
                _model.QueueBind(queueName, exchange, routingKey, filterInfo);

                return(true);
            });

            helper.Subscribe(typeof(T), new NullCallHandler(), hierarchy, filter);
        }
Esempio n. 2
0
        private static ISubscriptionHelper CreateSubscriptionHelper(IMessageConsumer consumer, IModel model, string queue, SubscriberConfigurator configurator)
        {
            ISubscriptionHelper helper = new SubscriptionHelper((type, filterInfo, handler) =>
            {
                if (consumer.Register(type, filterInfo, handler))
                {
                    model.QueueBind(queue, configurator.Exchange, configurator.RoutingKey, filterInfo);

                    return(true);
                }

                return(false);
            });

            return(helper);
        }
Esempio n. 3
0
        public Receiver(IModel model, string busId, string queue, IMessageHelper messageHelper, SubscriberConfigurator configurator)
        {
            _model = model;
            _busId = busId;

            _queue              = queue;
            _messageHelper      = messageHelper;
            _serializers        = configurator.Serializers;
            _errorSubscriber    = configurator.ErrorSubscriber;
            _receiveSelfPublish = configurator.ReceiveSelfPublish;

            _helper = new SubscriptionHelper((type, filterInfo, handler) =>
            {
                if (_nameMappings.TryAdd(type, filterInfo))
                {
                    _model.QueueBind(_queue, configurator.Exchange, configurator.RoutingKey, filterInfo);

                    return(true);
                }

                return(false);
            });
        }