Ejemplo n.º 1
0
        public override IReceiveEndpoint Build()
        {
            var builder = new RabbitMqReceiveEndpointBuilder(this);

            ApplySpecifications(builder);

            var receivePipe = CreateReceivePipe();

            var receiveEndpointContext = builder.CreateReceiveEndpointContext();

            _modelConfigurator.UseFilter(new ConfigureTopologyFilter <ReceiveSettings>(_settings, receiveEndpointContext.BrokerTopology));

            IAgent consumerAgent;

            if (_hostConfiguration.BusConfiguration.DeployTopologyOnly)
            {
                var transportReadyFilter = new TransportReadyFilter <ModelContext>(builder.TransportObservers, InputAddress);
                _modelConfigurator.UseFilter(transportReadyFilter);

                consumerAgent = transportReadyFilter;
            }
            else
            {
                if (_settings.PurgeOnStartup)
                {
                    _modelConfigurator.UseFilter(new PurgeOnStartupFilter(_settings.QueueName));
                }

                _modelConfigurator.UseFilter(new PrefetchCountFilter(_managementPipe, _settings.PrefetchCount));

                var deadLetterTransport = CreateDeadLetterTransport();

                var errorTransport = CreateErrorTransport();

                var consumerFilter = new RabbitMqConsumerFilter(receivePipe, builder.ReceiveObservers, builder.TransportObservers, receiveEndpointContext,
                                                                deadLetterTransport, errorTransport);

                _modelConfigurator.UseFilter(consumerFilter);

                consumerAgent = consumerFilter;
            }

            IFilter <ConnectionContext> modelFilter = new ReceiveModelFilter(_modelConfigurator.Build(), _hostConfiguration.Host);

            _connectionConfigurator.UseFilter(modelFilter);

            var transport = new RabbitMqReceiveTransport(_hostConfiguration.Host, _settings, _connectionConfigurator.Build(), receiveEndpointContext,
                                                         builder.ReceiveObservers, builder.TransportObservers);

            transport.Add(consumerAgent);

            return(CreateReceiveEndpoint(_settings.QueueName ?? NewId.Next().ToString(), transport, receivePipe, receiveEndpointContext));
        }
        public void Apply(IPipeBuilder <ConnectionContext> builder)
        {
            IPipe <ModelContext> pipe = Pipe.New <ModelContext>(x =>
            {
                x.UseFilter(new PrepareReceiveQueueFilter(_settings, _managementPipe, _exchangeBindings));

                x.UseFilter(new RabbitMqConsumerFilter(_receivePipe, _receiveObserver, _endpointObserver, _supervisor));
            });

            IFilter <ConnectionContext> modelFilter = new ReceiveModelFilter(pipe, _supervisor, _modelSettings);

            builder.AddFilter(modelFilter);
        }
Ejemplo n.º 3
0
        public void Apply(IPipeBuilder <ConnectionContext> builder)
        {
            IPipe <ModelContext> pipe = Pipe.New <ModelContext>(x =>
            {
                x.UseFilter(new ConfigureTopologyFilter <ReceiveSettings>(_settings, _topology.BrokerTopology));

                if (_settings.PurgeOnStartup)
                {
                    x.UseFilter(new PurgeOnStartupFilter(_settings.QueueName));
                }

                x.UseFilter(new PrefetchCountFilter(_managementPipe, _settings.PrefetchCount));

                x.UseFilter(new RabbitMqConsumerFilter(_receivePipe, _receiveObserver, _transportObserver, _supervisor, _topology));
            });

            IFilter <ConnectionContext> modelFilter = new ReceiveModelFilter(pipe, _supervisor, _host);

            builder.AddFilter(modelFilter);
        }