public void Build(IAmazonSqsHostControl host)
        {
            var builder = new AmazonSqsReceiveEndpointBuilder(host, _hostConfiguration.Settings, this);

            ApplySpecifications(builder);

            var receiveEndpointContext = builder.CreateReceiveEndpointContext();

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

            IAgent consumerAgent;

            if (_hostConfiguration.DeployTopologyOnly)
            {
                var transportReadyFilter = new TransportReadyFilter <ClientContext>(receiveEndpointContext);
                _clientConfigurator.UseFilter(transportReadyFilter);

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

                var consumerFilter = new AmazonSqsConsumerFilter(receiveEndpointContext);

                _clientConfigurator.UseFilter(consumerFilter);

                consumerAgent = consumerFilter;
            }

            IFilter <ConnectionContext> clientFilter = new ReceiveClientFilter(_clientConfigurator.Build());

            _connectionConfigurator.UseFilter(clientFilter);

            var transport = new SqsReceiveTransport(host, _settings, _connectionConfigurator.Build(), receiveEndpointContext);

            transport.Add(consumerAgent);

            var receiveEndpoint = new ReceiveEndpoint(transport, receiveEndpointContext);

            var queueName = _settings.EntityName ?? NewId.Next().ToString(FormatUtil.Formatter);

            host.AddReceiveEndpoint(queueName, receiveEndpoint);

            ReceiveEndpoint = receiveEndpoint;
        }
        public override IReceiveEndpoint Build()
        {
            var builder = new AmazonSqsReceiveEndpointBuilder(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
            {
                var deadLetterTransport = CreateDeadLetterTransport();

                var errorTransport = CreateErrorTransport();

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

                _modelConfigurator.UseFilter(consumerFilter);

                consumerAgent = consumerFilter;
            }

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

            _connectionConfigurator.UseFilter(sessionFilter);

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

            transport.Add(consumerAgent);

            return(CreateReceiveEndpoint(_settings.EntityName ?? NewId.Next().ToString(), transport, receivePipe, receiveEndpointContext));
        }
        public override IReceiveEndpoint Build()
        {
            var builder = new AmazonSqsReceiveEndpointBuilder(this);

            ApplySpecifications(builder);

            var receiveEndpointContext = builder.CreateReceiveEndpointContext();

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

            IAgent consumerAgent;

            if (_hostConfiguration.BusConfiguration.DeployTopologyOnly)
            {
                var transportReadyFilter = new TransportReadyFilter <ClientContext>(receiveEndpointContext);
                _clientConfigurator.UseFilter(transportReadyFilter);

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

                var consumerFilter = new AmazonSqsConsumerFilter(receiveEndpointContext);

                _clientConfigurator.UseFilter(consumerFilter);

                consumerAgent = consumerFilter;
            }

            IFilter <ConnectionContext> clientFilter = new ReceiveClientFilter(_clientConfigurator.Build());

            _connectionConfigurator.UseFilter(clientFilter);

            var transport = new SqsReceiveTransport(_hostConfiguration.Host, _settings, _connectionConfigurator.Build(), receiveEndpointContext);

            transport.Add(consumerAgent);

            return(CreateReceiveEndpoint(_settings.EntityName ?? NewId.Next().ToString(), transport, receiveEndpointContext));
        }
Example #4
0
        public void Build(IHost host)
        {
            var builder = new AmazonSqsReceiveEndpointBuilder(_hostConfiguration, this);

            ApplySpecifications(builder);

            var receiveEndpointContext = builder.CreateReceiveEndpointContext(_settings);

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

            if (_hostConfiguration.DeployTopologyOnly)
            {
                _clientConfigurator.UseFilter(new TransportReadyFilter <ClientContext>(receiveEndpointContext));
            }
            else
            {
                if (_settings.PurgeOnStartup)
                {
                    _clientConfigurator.UseFilter(new PurgeOnStartupFilter(_settings.EntityName));
                }

                _clientConfigurator.UseFilter(new AmazonSqsConsumerFilter(receiveEndpointContext));
            }

            IPipe <ClientContext> clientPipe = _clientConfigurator.Build();

            var transport = new ReceiveTransport <ClientContext>(_hostConfiguration, receiveEndpointContext,
                                                                 () => receiveEndpointContext.ClientContextSupervisor, clientPipe);

            var receiveEndpoint = new ReceiveEndpoint(transport, receiveEndpointContext);

            var queueName = _settings.EntityName ?? NewId.Next().ToString(FormatUtil.Formatter);

            host.AddReceiveEndpoint(queueName, receiveEndpoint);

            ReceiveEndpoint = receiveEndpoint;
        }