public void Build(IHost host)
        {
            var context = CreateRabbitMqReceiveEndpointContext();

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

            if (_hostConfiguration.DeployTopologyOnly)
            {
                _modelConfigurator.UseFilter(new TransportReadyFilter <ModelContext>(context));
            }
            else
            {
                if (_settings.PurgeOnStartup)
                {
                    _modelConfigurator.UseFilter(new PurgeOnStartupFilter(_settings.QueueName));
                }

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

                _modelConfigurator.UseFilter(new RabbitMqConsumerFilter(context));
            }

            IPipe <ModelContext> modelPipe = _modelConfigurator.Build();

            var transport = new ReceiveTransport <ModelContext>(_hostConfiguration, context, () => context.ModelContextSupervisor, modelPipe);

            var receiveEndpoint = new ReceiveEndpoint(transport, context);

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

            host.AddReceiveEndpoint(queueName, receiveEndpoint);

            ReceiveEndpoint = receiveEndpoint;
        }
Ejemplo n.º 2
0
        public void Build(IHost host)
        {
            var context = CreateActiveMqReceiveEndpointContext();

            _sessionConfigurator.UseFilter(new ConfigureTopologyFilter <ReceiveSettings>(_settings, context.BrokerTopology));

            if (_hostConfiguration.DeployTopologyOnly)
            {
                _sessionConfigurator.UseFilter(new TransportReadyFilter <SessionContext>(context));
            }
            else
            {
                _sessionConfigurator.UseFilter(new ActiveMqConsumerFilter(context));
            }

            IPipe <SessionContext> sessionPipe = _sessionConfigurator.Build();

            var transport = new ReceiveTransport <SessionContext>(_hostConfiguration, context,
                                                                  () => context.SessionContextSupervisor, sessionPipe);

            var receiveEndpoint = new ReceiveEndpoint(transport, context);

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

            host.AddReceiveEndpoint(queueName, receiveEndpoint);

            ReceiveEndpoint = receiveEndpoint;
        }
Ejemplo n.º 3
0
        public void Build(IHost host)
        {
            var context = CreateSqsReceiveEndpointContext();

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

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

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

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

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

            var receiveEndpoint = new ReceiveEndpoint(transport, context);

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

            host.AddReceiveEndpoint(queueName, receiveEndpoint);

            ReceiveEndpoint = receiveEndpoint;
        }
Ejemplo n.º 4
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 Build(IRabbitMqHostControl host)
        {
            var builder = new RabbitMqReceiveEndpointBuilder(host, this);

            ApplySpecifications(builder);

            var receiveEndpointContext = builder.CreateReceiveEndpointContext();

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

            IAgent consumerAgent;

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

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

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

                var consumerFilter = new RabbitMqConsumerFilter(receiveEndpointContext);

                _modelConfigurator.UseFilter(consumerFilter);

                consumerAgent = consumerFilter;
            }

            IFilter <ConnectionContext> modelFilter = new ReceiveEndpointFilter(_modelConfigurator.Build());

            _connectionConfigurator.UseFilter(modelFilter);

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

            transport.Add(consumerAgent);

            var receiveEndpoint = new ReceiveEndpoint(transport, receiveEndpointContext);

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

            host.AddReceiveEndpoint(queueName, receiveEndpoint);

            ReceiveEndpoint = receiveEndpoint;
        }
        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;
        }
Ejemplo n.º 7
0
        protected IReceivePipe CreateReceivePipe(IBusBuilder builder, Func <IConsumePipe, IReceiveEndpointBuilder> endpointBuilderFactory)
        {
            IConsumePipe consumePipe = _consumePipe ?? builder.CreateConsumePipe(_consumePipeConfigurator);

            IReceiveEndpointBuilder endpointBuilder = endpointBuilderFactory(consumePipe);

            foreach (IReceiveEndpointSpecification specification in _specifications)
            {
                specification.Configure(endpointBuilder);
            }

            ConfigureAddDeadLetterFilter(builder.SendTransportProvider);

            var publishEndpointProvider = builder.CreatePublishEndpointProvider(_publishPipeConfigurator);

            ConfigureRescueFilter(publishEndpointProvider, builder.SendTransportProvider);

            ISendEndpointProvider sendEndpointProvider = builder.CreateSendEndpointProvider(_sendPipeConfigurator);

            IMessageDeserializer messageDeserializer = builder.GetMessageDeserializer(sendEndpointProvider, publishEndpointProvider);

            _receiveConfigurator.UseFilter(new DeserializeFilter(messageDeserializer, consumePipe));

            var receivePipe = _receiveConfigurator.Build();

            return(new ReceivePipe(receivePipe, consumePipe));
        }
        IReceivePipe IReceivePipeConfiguration.CreatePipe(IConsumePipe consumePipe, IMessageDeserializer messageDeserializer,
                                                          Action <IPipeConfigurator <ReceiveContext> > configure)
        {
            if (_created)
            {
                throw new ConfigurationException("The ReceivePipeConfiguration can only be used once.");
            }

            if (configure == null)
            {
                DeadLetterConfigurator.UseFilter(new DeadLetterTransportFilter());
                _configurator.UseDeadLetter(DeadLetterConfigurator.Build());

                ErrorConfigurator.UseFilter(new GenerateFaultFilter());
                ErrorConfigurator.UseFilter(new ErrorTransportFilter());

                _configurator.UseRescue(ErrorConfigurator.Build(), x =>
                {
                    x.Ignore <OperationCanceledException>();
                });
            }
            else
            {
                configure(_configurator);
            }

            _configurator.UseFilter(new DeserializeFilter(messageDeserializer, consumePipe));

            _created = true;

            return(new ReceivePipe(_configurator.Build(), consumePipe));
        }
        public override IReceiveEndpoint Build()
        {
            var builder = new ActiveMqReceiveEndpointBuilder(this);

            ApplySpecifications(builder);

            var receivePipe = CreateReceivePipe();

            var receiveEndpointContext = builder.CreateReceiveEndpointContext();

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

            IAgent consumerAgent;

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

                consumerAgent = transportReadyFilter;
            }
            else
            {
                var deadLetterTransport = CreateDeadLetterTransport();

                var errorTransport = CreateErrorTransport();

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

                _sessionConfigurator.UseFilter(consumerFilter);

                consumerAgent = consumerFilter;
            }

            IFilter <ConnectionContext> sessionFilter = new ReceiveSessionFilter(_sessionConfigurator.Build(), _hostConfiguration.Host);

            _connectionConfigurator.UseFilter(sessionFilter);

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

            transport.Add(consumerAgent);

            return(CreateReceiveEndpoint(_settings.EntityName ?? NewId.Next().ToString(), transport, receivePipe, receiveEndpointContext));
        }
Ejemplo n.º 10
0
        public IConsumePipe BuildConsumePipe()
        {
            var filter = new DynamicFilter <ConsumeContext, Guid>(new ConsumeContextConverterFactory(), GetRequestId);

            _consumePipeConfigurator.UseFilter(filter);

            return(new ConsumePipe(this, filter, _consumePipeConfigurator.Build(), AutoStart));
        }
        public void Build(IHost host)
        {
            var builder = new ActiveMqReceiveEndpointBuilder(_hostConfiguration, this);

            ApplySpecifications(builder);

            var receiveEndpointContext = builder.CreateReceiveEndpointContext();

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

            IAgent consumerAgent;

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

                consumerAgent = transportReadyFilter;
            }
            else
            {
                var consumerFilter = new ActiveMqConsumerFilter(receiveEndpointContext);

                _sessionConfigurator.UseFilter(consumerFilter);

                consumerAgent = consumerFilter;
            }

            IFilter <ConnectionContext> sessionFilter = new ReceiveSessionFilter(_sessionConfigurator.Build());

            _connectionConfigurator.UseFilter(sessionFilter);

            var transport = new ActiveMqReceiveTransport(_hostConfiguration, _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 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));
        }
Ejemplo n.º 13
0
        public IReceivePipe CreatePipe(IConsumePipe consumePipe, IMessageDeserializer messageDeserializer)
        {
            if (_created)
            {
                throw new ConfigurationException("The ReceivePipeConfiguration can only be used once.");
            }

            _deadLetterPipeConfigurator.UseFilter(new DeadLetterTransportFilter());
            _configurator.UseDeadLetter(_deadLetterPipeConfigurator.Build());

            _errorPipeConfigurator.UseFilter(new GenerateFaultFilter());
            _errorPipeConfigurator.UseFilter(new ErrorTransportFilter());
            _configurator.UseRescue(_errorPipeConfigurator.Build());

            _configurator.UseFilter(new DeserializeFilter(messageDeserializer, consumePipe));

            _created = true;

            return(new ReceivePipe(_configurator.Build(), consumePipe));
        }
Ejemplo n.º 14
0
        public IPipe <SagaConsumeContext <TSaga, TMessage> > Build(IFilter <SagaConsumeContext <TSaga, TMessage> > consumeFilter)
        {
            _observers.All(observer =>
            {
                observer.SagaMessageConfigured(this);
                return(true);
            });

            _configurator.UseFilter(consumeFilter);

            return(_configurator.Build());
        }
        protected IReceivePipe CreateReceivePipe(IReceiveEndpointBuilder builder)
        {
            foreach (var specification in _specifications)
            {
                specification.Configure(builder);
            }

            _receiveConfigurator.UseDeadLetterQueue(Pipe.New <ReceiveContext>(x => x.UseFilter(new MoveToTransportFilter(DeadLetterAddress, "dead-letter"))));
            _receiveConfigurator.UseRescue(Pipe.New <ExceptionReceiveContext>(x => x.UseFilter(new MoveExceptionToTransportFilter(ErrorAddress))));
            _receiveConfigurator.UseFilter(new DeserializeFilter(builder.MessageDeserializer, builder.ConsumePipe));

            IPipe <ReceiveContext> receivePipe = _receiveConfigurator.Build();

            return(new ReceivePipe(receivePipe, builder.ConsumePipe));
        }
Ejemplo n.º 16
0
        public void Configure(IReceiveEndpointBuilder builder)
        {
            _activityPipeConfigurator.UseFilter(new ExecuteActivityFilter <TActivity, TArguments>(_observers));

            IPipe <ExecuteActivityContext <TActivity, TArguments> > executeActivityPipe = _activityPipeConfigurator.Build();

            _executePipeConfigurator.UseFilter(new ExecuteActivityFactoryFilter <TActivity, TArguments>(_activityFactory, executeActivityPipe));

            IPipe <ExecuteContext <TArguments> > executePipe = _executePipeConfigurator.Build();

            var host = new ExecuteActivityHost <TActivity, TArguments>(executePipe, _compensateAddress);

            _routingSlipConfigurator.UseFilter(host);

            builder.ConnectConsumePipe(_routingSlipConfigurator.Build());
        }
Ejemplo n.º 17
0
        public void Configure(IReceiveEndpointBuilder builder)
        {
            _activityPipeConfigurator.UseFilter(new CompensateActivityFilter <TActivity, TLog>(_observers));

            IPipe <CompensateActivityContext <TActivity, TLog> > compensateActivityPipe = _activityPipeConfigurator.Build();

            _compensatePipeConfigurator.UseFilter(new CompensateActivityFactoryFilter <TActivity, TLog>(_activityFactory, compensateActivityPipe));

            IPipe <CompensateContext <TLog> > compensatePipe = _compensatePipeConfigurator.Build();

            var host = new CompensateActivityHost <TActivity, TLog>(compensatePipe);

            _routingSlipConfigurator.UseFilter(host);

            builder.ConnectConsumePipe(_routingSlipConfigurator.Build());
        }
        protected IReceivePipe CreateReceivePipe(IReceiveEndpointBuilder builder)
        {
            foreach (var specification in _specifications)
            {
                specification.Configure(builder);
            }

            AddDeadLetterFilter(builder);

            AddRescueFilter(builder);

            _receiveConfigurator.UseFilter(new DeserializeFilter(builder.MessageDeserializer, builder.ConsumePipe));

            IPipe <ReceiveContext> receivePipe = _receiveConfigurator.Build();

            return(new ReceivePipe(receivePipe, builder.ConsumePipe));
        }
        protected IPipe <ReceiveContext> CreateReceivePipe(IBusBuilder builder, Func <IConsumePipe, IReceiveEndpointBuilder> endpointBuilderFactory)
        {
            IConsumePipe consumePipe = _consumePipe ?? builder.CreateConsumePipe(_consumePipeSpecification);

            IReceiveEndpointBuilder endpointBuilder = endpointBuilderFactory(consumePipe);

            foreach (IReceiveEndpointSpecification specification in _specifications)
            {
                specification.Configure(endpointBuilder);
            }

            ConfigureAddDeadLetterFilter(builder.SendTransportProvider);

            ConfigureRescueFilter(builder.SendTransportProvider);

            _receiveConfigurator.UseFilter(new DeserializeFilter(builder.MessageDeserializer, consumePipe));

            return(_receiveConfigurator.Build());
        }
Ejemplo n.º 20
0
        public IReceivePipe CreatePipe(IConsumePipe consumePipe, IMessageDeserializer messageDeserializer)
        {
            if (_created)
            {
                throw new ConfigurationException("The ReceivePipeConfiguration can only be used once.");
            }

            _configurator.UseDeadLetter(CreateDeadLetterPipe());
            _configurator.UseRescue(CreateErrorPipe(), x =>
            {
                x.Ignore <OperationCanceledException>();
            });

            _configurator.UseFilter(new DeserializeFilter(messageDeserializer, consumePipe));

            _created = true;

            return(new ReceivePipe(_configurator.Build(), consumePipe));
        }
Ejemplo n.º 21
0
        public IPipe <ConsumerConsumeContext <TConsumer, Batch <TMessage> > > Build(IFilter <ConsumerConsumeContext <TConsumer, Batch <TMessage> > > consumeFilter)
        {
            _batchConfigurator.UseFilter(consumeFilter);

            return(_batchConfigurator.Build());
        }