public InMemoryReceiveEndpointBuilder(IBusBuilder busBuilder, InMemoryHost host, ISendTransportProvider sendTransportProvider, IInMemoryEndpointConfiguration configuration)
     : base(busBuilder, configuration)
 {
     _host = host;
     _sendTransportProvider = sendTransportProvider;
     _configuration         = configuration;
 }
Exemple #2
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));
        }
Exemple #3
0
 public HttpReceiveEndpointBuilder(IBusBuilder busBuilder, IHttpHost host, BusHostCollection <HttpHost> hosts, IHttpEndpointConfiguration configuration)
     : base(busBuilder, configuration)
 {
     _host          = host;
     _configuration = configuration;
     _hosts         = hosts;
 }
Exemple #4
0
 private void ConfigureSubscriptions(IBusBuilder builder)
 {
     builder.SubscribeToEvent<ItemProduced>(ctx =>
     {
         Console.WriteLine($"{ctx.Message.Quantity} of {ctx.Message.ItemId} produced.");
         return Task.CompletedTask;
     });
 }
Exemple #5
0
 public ServiceBusSubscriptionEndpointBuilder(IBusBuilder busBuilder, IServiceBusHost host, IServiceBusEndpointConfiguration configuration,
                                              ISendTransportProvider sendTransportProvider)
     : base(busBuilder, configuration)
 {
     _configuration         = configuration;
     _host                  = host;
     _sendTransportProvider = sendTransportProvider;
 }
Exemple #6
0
        public RabbitMqReceiveEndpointBuilder(IConsumePipe consumePipe, IBusBuilder busBuilder, bool bindMessageExchanges, IRabbitMqHost host)
            : base(consumePipe, busBuilder)
        {
            _bindMessageExchanges = bindMessageExchanges;
            _host = host;

            _exchangeBindings = new List <ExchangeBindingSettings>();
        }
Exemple #7
0
        protected ReceiveEndpointBuilder(IBusBuilder builder, IEndpointConfiguration configuration)
        {
            _configuration = configuration;

            _consumePipe = configuration.Consume.CreatePipe();

            _serializerBuilder = builder.CreateSerializerBuilder();
        }
 public ServiceBusReceiveEndpointBuilder(IConsumePipe consumePipe, IBusBuilder busBuilder,
                                         bool subscribeMessageTopics, IServiceBusHost host)
     : base(consumePipe, busBuilder)
 {
     _subscribeMessageTopics = subscribeMessageTopics;
     _host = host;
     _topicSubscriptions = new List <TopicSubscriptionSettings>();
 }
Exemple #9
0
 public ServiceBusReceiveEndpointBuilder(IBusBuilder busBuilder, IServiceBusHost host, bool subscribeMessageTopics,
                                         IServiceBusEndpointConfiguration configuration, ISendTransportProvider sendTransportProvider)
     : base(busBuilder, configuration)
 {
     _subscribeMessageTopics = subscribeMessageTopics;
     _configuration          = configuration;
     _sendTransportProvider  = sendTransportProvider;
     _host = host;
 }
Exemple #10
0
 public RabbitMqReceiveEndpointBuilder(IBusBuilder busBuilder, IRabbitMqHost host, BusHostCollection <RabbitMqHost> hosts, bool bindMessageExchanges,
                                       IRabbitMqEndpointConfiguration configuration)
     : base(busBuilder, configuration)
 {
     _bindMessageExchanges = bindMessageExchanges;
     _configuration        = configuration;
     _host  = host;
     _hosts = hosts;
 }
Exemple #11
0
        public override void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new ServiceBusReceiveEndpointBuilder(CreateConsumePipe(builder), builder, _subscribeMessageTopics, Host);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            ApplyReceiveEndpoint(receiveEndpointBuilder, receivePipe,
                                 new PrepareReceiveEndpointFilter(_settings, receiveEndpointBuilder.GetTopicSubscriptions().Distinct().ToArray()),
                                 new PrepareQueueClientFilter(_settings));
        }
Exemple #12
0
        public override void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new ServiceBusReceiveEndpointBuilder(CreateConsumePipe(builder), builder, false, Host);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            ApplyReceiveEndpoint(receiveEndpointBuilder, receivePipe,
                                 new PrepareSubscriptionEndpointFilter(_settings),
                                 new PrepareSubscriptionClientFilter(_settings));
        }
        public override void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new ServiceBusReceiveEndpointBuilder(CreateConsumePipe(builder), builder, false, Host);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            ApplyReceiveEndpoint(receiveEndpointBuilder, receivePipe,
                new PrepareSubscriptionEndpointFilter(_settings),
                new PrepareSubscriptionClientFilter(_settings));
        }
        protected void ApplySpecifications(IBusBuilder builder)
        {
            foreach (IBusFactorySpecification configurator in _specifications)
            {
                configurator.Apply(builder);
            }

            foreach (IReceiveEndpointSpecification <IBusBuilder> configurator in _endpointSpecifications)
            {
                configurator.Apply(builder);
            }
        }
Exemple #15
0
        public static IObservable <EventContext <TEvent> > ObserveEvent <TEvent>(this IBusBuilder builder)
            where TEvent : class, IEvent
        {
            ISubject <EventContext <TEvent> > subject = new Subject <EventContext <TEvent> >();

            builder.SubscribeToEvent <TEvent>(msg =>
            {
                subject.OnNext(msg);
                return(Task.CompletedTask);
            });

            return(subject);
        }
        public override void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new ServiceBusSubscriptionEndpointBuilder(builder, Host, _configuration, _sendTransportProvider);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            var receiveEndpointTopology = receiveEndpointBuilder.CreateReceiveEndpointTopology(InputAddress, _settings);

            ApplyReceiveEndpoint(receivePipe, receiveEndpointTopology, x =>
            {
                x.UseFilter(new ConfigureTopologyFilter <SubscriptionSettings>(_settings, receiveEndpointTopology.BrokerTopology, false));
                x.UseFilter(new PrepareSubscriptionClientFilter(_settings));
            });
        }
        public void Apply(IBusBuilder builder)
        {
            RabbitMqReceiveEndpointBuilder endpointBuilder = null;
            var receivePipe = CreateReceivePipe(builder, consumePipe =>
            {
                endpointBuilder = new RabbitMqReceiveEndpointBuilder(consumePipe, _host.MessageNameFormatter);
                return endpointBuilder;
            });

            if (endpointBuilder == null)
                throw new InvalidOperationException("The endpoint builder was not initialized");

            var transport = new RabbitMqReceiveTransport(_host.ConnectionCache, _settings, endpointBuilder.GetExchangeBindings().ToArray());

            builder.AddReceiveEndpoint(new ReceiveEndpoint(transport, receivePipe));
        }
        public void Apply(IBusBuilder builder)
        {
            ServiceBusReceiveEndpointBuilder endpointBuilder = null;
            var receivePipe = CreateReceivePipe(builder, consumePipe =>
            {
                endpointBuilder = new ServiceBusReceiveEndpointBuilder(consumePipe, _host.MessageNameFormatter);
                return endpointBuilder;
            });

            if (endpointBuilder == null)
                throw new InvalidOperationException("The endpoint builder was not initialized");

            var transport = new ServiceBusReceiveTransport(_host, _settings, endpointBuilder.GetTopicSubscriptions().ToArray());

            builder.AddReceiveEndpoint(_settings.QueueDescription.Path, new ReceiveEndpoint(transport, receivePipe));
        }
Exemple #19
0
        /// <inheritdoc/>
        public void Apply(IBusBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (this.encryptionKey != null)
            {
                builder.SetMessageSerializer(this.GetMessageSerializer);
            }

            if (this.keyResolver != null)
            {
                builder.AddMessageDeserializer(EncryptedMessageSerializer.EncryptedContentType, this.GetMessageDeserializer);
            }
        }
Exemple #20
0
        public void Apply(IBusBuilder builder)
        {
            ServiceBusReceiveEndpointBuilder endpointBuilder = null;
            IPipe <ReceiveContext>           receivePipe     = CreateReceivePipe(builder, consumePipe =>
            {
                endpointBuilder = new ServiceBusReceiveEndpointBuilder(consumePipe, _host.MessageNameFormatter);
                return(endpointBuilder);
            });

            if (endpointBuilder == null)
            {
                throw new InvalidOperationException("The endpoint builder was not initialized");
            }

            var transport = new ServiceBusReceiveTransport(_host, _settings, endpointBuilder.GetTopicSubscriptions().ToArray());

            builder.AddReceiveEndpoint(new ReceiveEndpoint(transport, receivePipe));
        }
Exemple #21
0
        public void Apply(IBusBuilder builder)
        {
            RabbitMqReceiveEndpointBuilder endpointBuilder = null;
            var receivePipe = CreateReceivePipe(builder, consumePipe =>
            {
                endpointBuilder = new RabbitMqReceiveEndpointBuilder(consumePipe, _host.MessageNameFormatter);
                return(endpointBuilder);
            });

            if (endpointBuilder == null)
            {
                throw new InvalidOperationException("The endpoint builder was not initialized");
            }

            var transport = new RabbitMqReceiveTransport(_host, _settings, endpointBuilder.GetExchangeBindings().ToArray());

            builder.AddReceiveEndpoint(_settings.QueueName ?? NewId.Next().ToString(), new ReceiveEndpoint(transport, receivePipe));
        }
        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());
        }
        public void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new HttpReceiveEndpointBuilder(_host, CreateConsumePipe(builder), builder);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            _sendEndpointProvider = CreateSendEndpointProvider(receiveEndpointBuilder);
            _publishEndpointProvider = CreatePublishEndpointProvider(receiveEndpointBuilder);

            var sendPipe = builder.CreateSendPipe();

            var receiveSettings = new Settings(_pathMatch, receiveEndpointBuilder.MessageSerializer, _sendEndpointProvider, _publishEndpointProvider);

            var transport = new HttpReceiveTransport(_host, receiveSettings, sendPipe);

            var httpHost = _host as HttpHost;
            if (httpHost == null)
                throw new ConfigurationException("Must be a HttpHost");

            httpHost.ReceiveEndpoints.Add(NewId.Next().ToString(), new ReceiveEndpoint(transport, receivePipe));
        }
Exemple #24
0
        public IBusBuilder Configure(IBusBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }

            builder.Match <IServiceBusBuilder>(x =>
            {
                var settings = new ServiceBusSettings(builder.Settings);

                settings.InputAddress = _uri ?? builder.Settings.InputAddress.AppendToPath("_control");

                // the endpoint factory is already created, so we can't set the endpoint here
                // we really need this to be part of another step, but i don't have a clue how yet.
                //_configurator.ConfigureEndpoint(_uri, x => x.PurgeExistingMessages());

                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Configuring control bus for {0} at {1}", builder.Settings.InputAddress,
                                     settings.InputAddress);
                }

                settings.ConcurrentConsumerLimit = 1;
                settings.ConcurrentReceiverLimit = 1;
                settings.AutoStart = true;

                IBusBuilder controlBusBuilder = new ControlBusBuilder(settings);

                controlBusBuilder = _configurators
                                    .Aggregate(controlBusBuilder, (current, configurator) => configurator.Configure(current));

                IControlBus controlBus = controlBusBuilder.Build();

                x.UseControlBus(controlBus);
            });

            return(builder);
        }
        public IServiceBus CreateServiceBus()
        {
            LogAssemblyVersionInformation();

            IEndpointCache endpointCache = CreateEndpointCache();

            _settings.EndpointCache = endpointCache;

            IBusBuilder builder = _builderFactory(_settings);

            _subscriptionRouterConfigurator.SetNetwork(_settings.Network);

            // run through all configurators that have been set and let
            // them do their magic
            foreach (IBusBuilderConfigurator configurator in _configurators)
            {
                builder = configurator.Configure(builder);
            }

            IServiceBus bus = builder.Build();

            return(bus);
        }
        public void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new HttpReceiveEndpointBuilder(builder, _host, _hosts, _configuration);

            var receiveEndpointTopology = receiveEndpointBuilder.CreateReceiveEndpointTopology(InputAddress);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            _sendEndpointProvider    = receiveEndpointTopology.SendEndpointProvider;
            _publishEndpointProvider = receiveEndpointTopology.PublishEndpointProvider;

            var receiveSettings = new Settings(_pathMatch);

            var transport = new HttpReceiveTransport(_host, receiveSettings, receiveEndpointTopology);

            var httpHost = _host as HttpHost;

            if (httpHost == null)
            {
                throw new ConfigurationException("Must be a HttpHost");
            }

            httpHost.ReceiveEndpoints.Add(NewId.Next().ToString(), new ReceiveEndpoint(transport, receivePipe));
        }
Exemple #27
0
        public void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new HttpReceiveEndpointBuilder(_host, CreateConsumePipe(builder), builder);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            _sendEndpointProvider    = CreateSendEndpointProvider(receiveEndpointBuilder);
            _publishEndpointProvider = CreatePublishEndpointProvider(receiveEndpointBuilder);

            var sendPipe = builder.CreateSendPipe();

            var receiveSettings = new Settings(_pathMatch, receiveEndpointBuilder.MessageSerializer, _sendEndpointProvider, _publishEndpointProvider);

            var transport = new HttpReceiveTransport(_host, receiveSettings, sendPipe);

            var httpHost = _host as HttpHost;

            if (httpHost == null)
            {
                throw new ConfigurationException("Must be a HttpHost");
            }

            httpHost.ReceiveEndpoints.Add(NewId.Next().ToString(), new ReceiveEndpoint(transport, receivePipe));
        }
Exemple #28
0
 private void ConfigureSubscriptions(IBusBuilder builder)
 {
     builder.SubscribeToCommand<ReverseString>();
 }
Exemple #29
0
 public void Apply(IBusBuilder builder)
 {
     builder.SetMessageSerializer(() => new TSerializer());
 }
 protected IConsumePipe CreateConsumePipe(IBusBuilder builder)
 {
     return(_consumePipe ?? builder.CreateConsumePipe(_consumePipeSpecification));
 }
 public void Apply(IBusBuilder builder)
 {
     builder.AddMessageDeserializer(_contentType, _deserializerFactory);
 }
Exemple #32
0
 private void ConfigureSubscriptions(IBusBuilder builder)
 {
     builder.SubscribeToEvent<StringReversed>();
 }
        public void Apply(IBusBuilder builder)
        {
            var observer = new InMemorySchedulerBusObserver(_scheduler);

            builder.ConnectBusObserver(observer);
        }
        public override void Apply(IBusBuilder builder)
        {
            var receiveEndpointBuilder = new ServiceBusReceiveEndpointBuilder(CreateConsumePipe(builder), builder, _subscribeMessageTopics, Host);

            var receivePipe = CreateReceivePipe(receiveEndpointBuilder);

            ApplyReceiveEndpoint(receiveEndpointBuilder, receivePipe,
                new PrepareReceiveEndpointFilter(_settings, receiveEndpointBuilder.GetTopicSubscriptions().Distinct().ToArray()),
                new PrepareQueueClientFilter(_settings));
        }
Exemple #35
0
 private void ConfigureSubscriptions(IBusBuilder builder)
 {
     builder.SubscribeToCommand<ProduceItem>();
 }
        public void Apply(IBusBuilder builder)
        {
            builder.SetMessageSerializer(CreateSerializer);

            builder.AddMessageDeserializer(EncryptedMessageSerializer.EncryptedContentType, CreateDeserializer);
        }
        public void Apply(IBusBuilder builder)
        {
            var observer = _observerFactory();

            builder.ConnectBusObserver(observer);
        }
        public IBusBuilder Configure(IBusBuilder builder)
        {
            builder.AddBusServiceConfigurator(_configurator);

            return(builder);
        }
 public void Apply(IBusBuilder builder)
 {
     builder.AddMessageDeserializer(_contentType, _deserializerFactory);
 }
 public HttpReceiveEndpointBuilder(IHttpHost host, IConsumePipe consumePipe, IBusBuilder busBuilder)
     : base(consumePipe, busBuilder)
 {
     _host = host;
 }
        public void Apply(IBusBuilder builder)
        {
            var observer = _observerFactory();

            builder.ConnectBusObserver(observer);
        }
Exemple #42
0
 protected Configure()
 {
     Container = new StandardContainer();
     _busConfigurer = new BusBuilder();
     _busBuilder = _busConfigurer as IBusBuilder;
 }
        public void Apply(IBusBuilder builder)
        {
            var observer = new SchedulerBusObserver(_scheduler, _schedulerEndpointAddress);

            builder.ConnectBusObserver(observer);
        }
Exemple #44
0
 public void Apply(IBusBuilder builder)
 {
 }
Exemple #45
0
        public void Apply(IBusBuilder builder)
        {
            var observer = new SchedulerBusObserver(_scheduler, _schedulerEndpointAddress);

            builder.ConnectBusObserver(observer);
        }
        public void Apply(IBusBuilder builder)
        {
            var observer = new PerformanceCounterBusObserver(_factory);

            builder.ConnectBusObserver(observer);
        }
        public void Apply(IBusBuilder builder)
        {
            var observer = new PerformanceCounterBusObserver(_factory);

            builder.ConnectBusObserver(observer);
        }
 public InMemoryReceiveEndpointBuilder(IConsumePipe consumePipe, IBusBuilder busBuilder)
     : base(consumePipe, busBuilder)
 {
 }