示例#1
0
        public Bootstrapper(ServiceBase host = null, HostArguments hostArguments = null, Configure configure = null)
        {
            // .NET default limit is 10. RavenDB in conjunction with transports that use HTTP exceeds that limit.
            ServicePointManager.DefaultConnectionLimit = Settings.HttpDefaultConnectionLimit;

            Settings.ServiceName = DetermineServiceName(host, hostArguments);
            ConfigureLogging();
            var containerBuilder = new ContainerBuilder();
            Container = containerBuilder.Build();

            // Disable Auditing for the service control endpoint
            Configure.Features.Disable<Audit>();
            Configure.Features.Enable<Sagas>();
            Feature.Disable<AutoSubscribe>();
            Feature.Disable<SecondLevelRetries>();

            Configure.Serialization.Json();
            Configure.Transactions.Advanced(t => t.DisableDistributedTransactions().DoNotWrapHandlersExecutionInATransactionScope());

            Feature.EnableByDefault<StorageDrivenPublisher>();
            Configure.ScaleOut(s => s.UseSingleBrokerQueue());

            var transportType = DetermineTransportType();

            if (configure == null)
            {
                configure = Configure
                    .With(AllAssemblies.Except("ServiceControl.Plugin"));
            }

            bus = configure
                .DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t) || IsExternalContract(t))
                .DefineEndpointName(Settings.ServiceName)
                .AutofacBuilder(Container)
                .UseTransport(transportType)
                .MessageForwardingInCaseOfFault()
                .DefineCriticalErrorAction((s, exception) =>
                {
                    if (host != null)
                    {
                        host.Stop();
                    }
                })
                .UnicastBus()
                .CreateBus();
        }
        public Bootstrapper(ServiceBase host = null)
        {
            ConfigureLogging();

            var containerBuilder = new ContainerBuilder();

            Container = containerBuilder.Build();
            
            // Disable Auditing for the service control endpoint
            Configure.Features.Disable<Audit>();
            Configure.Features.Enable<Sagas>();
            Feature.Disable<AutoSubscribe>();
            Feature.Disable<SecondLevelRetries>();

            Configure.Serialization.Json();
            Configure.Transactions.Advanced(t => t.DisableDistributedTransactions());

            Feature.EnableByDefault<StorageDrivenPublisher>();
            Configure.ScaleOut(s => s.UseSingleBrokerQueue());

            var transportType = Type.GetType(Settings.TransportType);
            bus = Configure
                .With(AllAssemblies.Except("ServiceControl.Plugin"))
                .DefineEndpointName("Particular.ServiceControl")
                .AutofacBuilder(Container)
                .UseTransport(transportType)
                .MessageForwardingInCaseOfFault()
                .DefineCriticalErrorAction((s, exception) =>
                {
                    if (host != null)
                    {
                        host.Stop();
                    }
                })
                .UnicastBus()
                .CreateBus();
        }