Exemple #1
0
 public void FinalizeConfiguration()
 {
     if (SettingsHolder.GetOrDefault <bool>("UnicastBus.AutoSubscribe"))
     {
         InfrastructureServices.Enable <IAutoSubscriptionStrategy>();
     }
 }
        public override void Initialize()
        {
            if (!SettingsHolder.GetOrDefault <bool>("ScaleOut.UseSingleBrokerQueue"))
            {
                Address.InitializeLocalAddress(Address.Local.Queue + "." + Address.Local.Machine);
            }

            var connectionString        = SettingsHolder.Get <string>("NServiceBus.Transport.ConnectionString");
            var connectionConfiguration = new ConnectionStringParser().Parse(connectionString);

            NServiceBus.Configure.Instance.Configurer.RegisterSingleton <IConnectionConfiguration>(connectionConfiguration);

            NServiceBus.Configure.Component <RabbitMqDequeueStrategy>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.PurgeOnStartup, ConfigurePurging.PurgeRequested)
            .ConfigureProperty(p => p.PrefetchCount, connectionConfiguration.PrefetchCount);

            NServiceBus.Configure.Component <RabbitMqUnitOfWork>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.UsePublisherConfirms, connectionConfiguration.UsePublisherConfirms)
            .ConfigureProperty(p => p.MaxWaitTimeForConfirms, connectionConfiguration.MaxWaitTimeForConfirms);


            NServiceBus.Configure.Component <RabbitMqMessageSender>(DependencyLifecycle.InstancePerCall);

            NServiceBus.Configure.Component <RabbitMqMessagePublisher>(DependencyLifecycle.InstancePerCall);

            NServiceBus.Configure.Component <RabbitMqSubscriptionManager>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.EndpointQueueName, Address.Local.Queue);

            NServiceBus.Configure.Component <RabbitMqQueueCreator>(DependencyLifecycle.InstancePerCall);

            InfrastructureServices.Enable <IRoutingTopology>();
            InfrastructureServices.Enable <IManageRabbitMqConnections>();
        }
        public override void Initialize()
        {
            var connectionString        = SettingsHolder.Get <string>("NServiceBus.Transport.ConnectionString");
            var connectionConfiguration = new ConnectionStringParser().Parse(connectionString);

            NServiceBus.Configure.Instance.Configurer.RegisterSingleton <IConnectionConfiguration>(connectionConfiguration);
            NServiceBus.Configure.Component <DefaultConnectionManager>(DependencyLifecycle.SingleInstance);

            NServiceBus.Configure.Component <EventSourcedUnitOfWork>(DependencyLifecycle.InstancePerUnitOfWork)
            .ConfigureProperty(p => p.EndpointAddress, Address.Local);
            NServiceBus.Configure.Component <TransactionalUnitOfWork>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.EndpointAddress, Address.Local);

            NServiceBus.Configure.Component <MessageSender>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.EndpointAddress, Address.Local);
            NServiceBus.Configure.Component <MessagePublisher>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.EndpointAddress, Address.Local);

            NServiceBus.Configure.Component <TransactionalModeRouterProjectionCreator>(DependencyLifecycle.InstancePerCall);
            NServiceBus.Configure.Component <EventSourcedModeRouterProjectionCreator>(DependencyLifecycle.InstancePerCall);
            NServiceBus.Configure.Component <ReceiverSinkProjectionCreator>(DependencyLifecycle.InstancePerCall);
            NServiceBus.Configure.Component <CompositeQueueCreator>(DependencyLifecycle.InstancePerCall);

            NServiceBus.Configure.Component <DequeueStrategy>(DependencyLifecycle.InstancePerCall);
            NServiceBus.Configure.Component <SubscriptionManager>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.EndpointAddress, Address.Local);

            InfrastructureServices.Enable <IManageEventStoreConnections>();

            Features.Categories.Serializers.SetDefault <JsonNoBomSerialization>();
        }
 public static void RegisterDefaults()
 {
     InfrastructureServices.SetDefaultFor <ISagaPersister>(() => Configure.Instance.RavenSagaPersister());
     InfrastructureServices.SetDefaultFor <IPersistTimeouts>(() => Configure.Instance.UseRavenTimeoutPersister());
     InfrastructureServices.SetDefaultFor <IPersistMessages>(() => Configure.Instance.UseRavenGatewayPersister());
     InfrastructureServices.SetDefaultFor <ISubscriptionStorage>(() => Configure.Instance.RavenSubscriptionStorage());
 }
Exemple #5
0
        protected override void InternalConfigure(Configure config, string brokerUri)
        {
            connectionConfiguration = this.Parse(brokerUri);

            config.Configurer.ConfigureComponent <ActiveMqMessageSender>(DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent <ActiveMqMessagePublisher>(DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent <MessageProducer>(DependencyLifecycle.InstancePerCall);

            config.Configurer.ConfigureComponent <SubscriptionManager>(DependencyLifecycle.SingleInstance);

            config.Configurer.ConfigureComponent <ActiveMqMessageMapper>(DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent(() => new ActiveMqMessageDecoderPipeline(), DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent(() => new ActiveMqMessageEncoderPipeline(), DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent <MessageTypeInterpreter>(DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent <TopicEvaluator>(DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent <DestinationEvaluator>(DependencyLifecycle.InstancePerCall);

            config.Configurer.ConfigureComponent <ActiveMqQueueCreator>(DependencyLifecycle.InstancePerCall);

            config.Configurer.ConfigureComponent <ActiveMqMessageDequeueStrategy>(DependencyLifecycle.InstancePerCall);
            config.Configurer.ConfigureComponent <ActiveMqMessageReceiver>(DependencyLifecycle.InstancePerCall);

            config.Configurer.ConfigureComponent <NotifyMessageReceivedFactory>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.ConsumerName, NServiceBus.Configure.EndpointName);
            config.Configurer.ConfigureComponent <ActiveMqPurger>(DependencyLifecycle.SingleInstance);
            config.Configurer.ConfigureComponent <TransactionScopeFactory>(DependencyLifecycle.SingleInstance);

            InfrastructureServices.RegisterServiceFor <IAutoSubscriptionStrategy>(typeof(NoConfigRequiredAutoSubscriptionStrategy), DependencyLifecycle.InstancePerCall);

            EndpointInputQueueCreator.Enabled = true;
        }
Exemple #6
0
 public static void UseAsDefault()
 {
     InfrastructureServices.SetDefaultFor <ISagaPersister>(() => Configure.Instance.UseNHibernateSagaPersister());
     InfrastructureServices.SetDefaultFor <IPersistTimeouts>(() => Configure.Instance.UseNHibernateTimeoutPersister());
     InfrastructureServices.SetDefaultFor <IPersistMessages>(() => Configure.Instance.UseNHibernateGatewayPersister());
     InfrastructureServices.SetDefaultFor <ISubscriptionStorage>(() => Configure.Instance.UseNHibernateSubscriptionPersister());
 }
 public static void UseAsDefault()
 {
     InfrastructureServices.SetDefaultFor <ISagaPersister>(() => Configure.Instance.InMemorySagaPersister());
     InfrastructureServices.SetDefaultFor <IPersistTimeouts>(() => Configure.Instance.UseInMemoryTimeoutPersister());
     InfrastructureServices.SetDefaultFor <IPersistMessages>(() => Configure.Instance.UseInMemoryGatewayPersister());
     InfrastructureServices.SetDefaultFor <IDeduplicateMessages>(() => Configure.Instance.UseInMemoryGatewayDeduplication());
     InfrastructureServices.SetDefaultFor <ISubscriptionStorage>(() => Configure.Instance.InMemorySubscriptionStorage());
 }
Exemple #8
0
        public override void Initialize()
        {
            DispatcherAddress = Address.Parse(Configure.EndpointName).SubScope("TimeoutsDispatcher");
            InputAddress      = Address.Parse(Configure.EndpointName).SubScope("Timeouts");

            Configure.Component <TimeoutPersisterReceiver>(DependencyLifecycle.SingleInstance);

            InfrastructureServices.Enable <IPersistTimeouts>();
            InfrastructureServices.Enable <IManageTimeouts>();
        }
Exemple #9
0
        public override void Initialize()
        {
            ConfigureChannels();

            ConfigureReceiver();

            ConfigureSender();

            InfrastructureServices.Enable <IPersistMessages>();
        }
Exemple #10
0
        public override void Initialize()
        {
            var transportDefinition = SettingsHolder.GetOrDefault <TransportDefinition>("NServiceBus.Transport.SelectedTransport");

            if (transportDefinition != null && transportDefinition.HasNativePubSubSupport)
            {
                Logger.WarnFormat("The StorageDrivenPublisher feature is enabled but the transport has native pub/sub capabilities. Feature will not be initialized. This is most likely happening because you're specifying the As_a_Publisher role which is only relevant for transports without native pub/sub like Msmq, SqlServer etc");
                return;
            }

            Configure.Component <Unicast.Publishing.StorageDrivenPublisher>(DependencyLifecycle.InstancePerCall);

            InfrastructureServices.Enable <ISubscriptionStorage>();
        }
Exemple #11
0
        public override void Initialize()
        {
            var sagasFound = FindAndConfigureSagasIn(Configure.TypesToScan);

            if (sagasFound)
            {
                InfrastructureServices.Enable <ISagaPersister>();

                Logger.InfoFormat("Sagas found in scanned types, saga persister enabled");
            }
            else
            {
                Logger.InfoFormat("The saga feature was enabled but no saga implementations could be found. No need to enable the configured saga persister");
            }
        }
        public void FinalizeConfiguration()
        {
            var knownMessages = Configure.TypesToScan
                                .Where(MessageConventionExtensions.IsMessageType)
                                .ToList();

            RegisterMessageOwnersAndBusAddress(knownMessages);

            ConfigureMessageRegistry(knownMessages);

            if (SettingsHolder.GetOrDefault <bool>("UnicastBus.AutoSubscribe"))
            {
                InfrastructureServices.Enable <IAutoSubscriptionStrategy>();
            }
        }
Exemple #13
0
        public override void Initialize()
        {
            Configure.Component <ReplyingToNullOriginatorDispatcher>(DependencyLifecycle.SingleInstance);

            var sagasFound = FindAndConfigureSagasIn(Configure.TypesToScan);

            if (sagasFound)
            {
                InfrastructureServices.Enable <ISagaPersister>();

                Logger.InfoFormat("Sagas found in scanned types, saga persister enabled");
            }
            else
            {
                Logger.InfoFormat("The saga feature was enabled but no saga implementations could be found. No need to enable the configured saga persister");
            }
        }
Exemple #14
0
        public override void Initialize()
        {
            InfrastructureServices.Enable <IAutoSubscriptionStrategy>();

            if (Configure.HasComponent <DefaultAutoSubscriptionStrategy>())
            {
                var transportDefinition = SettingsHolder.GetOrDefault <TransportDefinition>("NServiceBus.Transport.SelectedTransport");

                //if the transport has centralized pubsub we can auto-subscribe all events regardless if they have explicit routing or not
                if (transportDefinition != null && transportDefinition.HasSupportForCentralizedPubSub)
                {
                    Configure.Instance.Configurer.ConfigureProperty <DefaultAutoSubscriptionStrategy>(s => s.DoNotRequireExplicitRouting, true);
                }

                //apply any user specific settings
                SettingsHolder.ApplyTo <DefaultAutoSubscriptionStrategy>();
            }
        }
        /// <summary>
        /// Use the direct routing topology with the given conventions
        /// </summary>
        /// <param name="routingKeyConvention"></param>
        /// <param name="exchangeNameConvention"></param>
        /// <returns></returns>
        public RabbitMqSettings UseDirectRoutingTopology(Func <Type, string> routingKeyConvention = null, Func <Address, Type, string> exchangeNameConvention = null)
        {
            if (routingKeyConvention == null)
            {
                routingKeyConvention = DefaultRoutingKeyConvention.GenerateRoutingKey;
            }

            if (exchangeNameConvention == null)
            {
                exchangeNameConvention = (address, eventType) => "amq.topic";
            }

            InfrastructureServices.RegisterServiceFor <IRoutingTopology>(() =>
            {
                var router = new DirectRoutingTopology
                {
                    ExchangeNameConvention = exchangeNameConvention,
                    RoutingKeyConvention   = routingKeyConvention
                };

                Configure.Instance.Configurer.RegisterSingleton <IRoutingTopology>(router);
            });
            return(this);
        }
 /// <summary>
 /// Setup the defaults
 /// </summary>
 public RabbitMqSettings()
 {
     InfrastructureServices.SetDefaultFor <IRoutingTopology>(typeof(ConventionalRoutingTopology), DependencyLifecycle.SingleInstance);
     InfrastructureServices.SetDefaultFor <IManageRabbitMqConnections>(ConfigureDefaultConnectionManager);
 }
Exemple #17
0
 public AutoSubscribeSettings()
 {
     InfrastructureServices.SetDefaultFor <IAutoSubscriptionStrategy>(typeof(DefaultAutoSubscriptionStrategy), DependencyLifecycle.SingleInstance);
 }
Exemple #18
0
 /// <summary>
 /// Registers a custom auto-subscription strategy
 /// </summary>
 public AutoSubscribeSettings CustomAutoSubscriptionStrategy <T>() where T : IAutoSubscriptionStrategy
 {
     InfrastructureServices.RegisterServiceFor <IAutoSubscriptionStrategy>(typeof(T), DependencyLifecycle.SingleInstance);
     return(this);
 }
 /// <summary>
 /// Register a custom routing topology
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public RabbitMqSettings UseRoutingTopology <T>()
 {
     InfrastructureServices.RegisterServiceFor <IRoutingTopology>(typeof(T), DependencyLifecycle.SingleInstance);
     return(this);
 }
 /// <summary>
 /// Registers a custom connection manager te be used
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public RabbitMqSettings UseConnectionManager <T>()
 {
     InfrastructureServices.RegisterServiceFor <IManageRabbitMqConnections>(typeof(T), DependencyLifecycle.SingleInstance);
     return(this);
 }
Exemple #21
0
 public void Init()
 {
     InfrastructureServices.SetDefaultFor <IManageTimeouts>(typeof(DefaultTimeoutManager), DependencyLifecycle.SingleInstance);
 }