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));
        }
예제 #2
0
        public void Build(IActiveMqHostControl host)
        {
            var builder = new ActiveMqReceiveEndpointBuilder(host, 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(), host);

            _connectionConfigurator.UseFilter(sessionFilter);

            var transport = new ActiveMqReceiveTransport(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;
        }