public static Task <IStartableEndpoint> Create(Settings.Settings settings, TransportCustomization transportCustomization, TransportSettings transportSettings, LoggingSettings loggingSettings, IContainer container, Action <ICriticalErrorContext> onCriticalError, EmbeddableDocumentStore documentStore, EndpointConfiguration configuration, bool isRunningAcceptanceTests)
        {
            var endpointName = settings.ServiceName;

            if (configuration == null)
            {
                configuration = new EndpointConfiguration(endpointName);
                var assemblyScanner = configuration.AssemblyScanner();
                assemblyScanner.ExcludeAssemblies("ServiceControl.Plugin");
            }

            configuration.Pipeline.Register(typeof(FullTypeNameOnlyBehavior), "Remove asm qualified name from the message type header");

            // HACK: Yes I know, I am hacking it to pass it to RavenBootstrapper!
            configuration.GetSettings().Set(documentStore);
            configuration.GetSettings().Set("ServiceControl.Settings", settings);

            configuration.SendOnly();

            transportCustomization.CustomizeSendOnlyEndpoint(configuration, transportSettings);
            //DisablePublishing API is available only on TransportExtensions for transports that implement IMessageDrivenPubSub so we need to set settings directly
            configuration.GetSettings().Set("NServiceBus.PublishSubscribe.EnablePublishing", false);

            var routing = new RoutingSettings(configuration.GetSettings());

            routing.RouteToEndpoint(typeof(RegisterNewEndpoint), settings.ServiceControlQueueAddress);
            routing.RouteToEndpoint(typeof(MarkMessageFailureResolvedByRetry), settings.ServiceControlQueueAddress);

            configuration.GetSettings().Set(loggingSettings);
            configuration.SetDiagnosticsPath(loggingSettings.LogPath);

            // sagas are not auto-disabled for send-only endpoints
            configuration.DisableFeature <Sagas>();

            configuration.UseSerialization <NewtonsoftSerializer>();

            configuration.Conventions().DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t) || IsExternalContract(t));

            if (!isRunningAcceptanceTests)
            {
                configuration.ReportCustomChecksTo(settings.ServiceControlQueueAddress);
            }

#pragma warning disable CS0618 // Type or member is obsolete
            configuration.UseContainer <AutofacBuilder>(c => c.ExistingLifetimeScope(container));
#pragma warning restore CS0618 // Type or member is obsolete

            configuration.DefineCriticalErrorAction(criticalErrorContext =>
            {
                onCriticalError(criticalErrorContext);
                return(Task.FromResult(0));
            });

            if (Environment.UserInteractive && Debugger.IsAttached)
            {
                configuration.EnableInstallers();
            }

            return(Endpoint.Create(configuration));
        }
        public static Task <IStartableEndpoint> Create(Settings.Settings settings, TransportCustomization transportCustomization, TransportSettings transportSettings, LoggingSettings loggingSettings, IContainer container, Action <ICriticalErrorContext> onCriticalError, EmbeddableDocumentStore documentStore, EndpointConfiguration configuration, bool isRunningAcceptanceTests)
        {
            var endpointName = settings.ServiceName;

            if (configuration == null)
            {
                configuration = new EndpointConfiguration(endpointName);
                var assemblyScanner = configuration.AssemblyScanner();
                assemblyScanner.ExcludeAssemblies("ServiceControl.Plugin");
            }

            // HACK: Yes I know, I am hacking it to pass it to RavenBootstrapper!
            configuration.GetSettings().Set(documentStore);
            configuration.GetSettings().Set("ServiceControl.Settings", settings);

            MapSettings(transportSettings, settings);

            transportCustomization.CustomizeEndpoint(configuration, transportSettings);

            configuration.GetSettings().Set(loggingSettings);

            // Disable Auditing for the service control endpoint
            configuration.DisableFeature <Audit>();
            configuration.DisableFeature <AutoSubscribe>();
            configuration.DisableFeature <TimeoutManager>();
            configuration.DisableFeature <Outbox>();

            var recoverability = configuration.Recoverability();

            recoverability.Immediate(c => c.NumberOfRetries(3));
            recoverability.Delayed(c => c.NumberOfRetries(0));
            configuration.SendFailedMessagesTo($"{endpointName}.Errors");

            configuration.UseSerialization <NewtonsoftSerializer>();

            configuration.LimitMessageProcessingConcurrencyTo(settings.MaximumConcurrencyLevel);

            configuration.Conventions().DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t) || IsExternalContract(t));

            if (!isRunningAcceptanceTests)
            {
                configuration.ReportCustomChecksTo(endpointName);
            }

            configuration.UseContainer <AutofacBuilder>(c => c.ExistingLifetimeScope(container));

            configuration.DefineCriticalErrorAction(criticalErrorContext =>
            {
                onCriticalError(criticalErrorContext);
                return(Task.FromResult(0));
            });

            if (Environment.UserInteractive && Debugger.IsAttached)
            {
                configuration.EnableInstallers();
            }

            return(Endpoint.Create(configuration));
        }
        public static async Task <BusInstance> CreateAndStart(Settings.Settings settings, TransportCustomization transportCustomization, TransportSettings transportSettings, LoggingSettings loggingSettings, IContainer container, EmbeddableDocumentStore documentStore, EndpointConfiguration configuration, bool isRunningAcceptanceTests)
        {
            var startableEndpoint = await Create(settings, transportCustomization, transportSettings, loggingSettings, container, documentStore, configuration, isRunningAcceptanceTests)
                                    .ConfigureAwait(false);

            var domainEvents   = container.Resolve <IDomainEvents>();
            var errorIngestion = container.Resolve <ErrorIngestionComponent>();

            var endpointInstance = await startableEndpoint.Start().ConfigureAwait(false);

            var builder = new ContainerBuilder();

            builder.RegisterInstance(endpointInstance).As <IMessageSession>();

            builder.Update(container.ComponentRegistry);

            return(new BusInstance(endpointInstance, domainEvents, errorIngestion));
        }
 public RawEndpointFactory(Settings settings, TransportSettings transportSettings, TransportCustomization transportCustomization)
 {
     this.transportSettings      = transportSettings;
     this.settings               = settings;
     this.transportCustomization = transportCustomization;
 }
Example #5
0
        static Func <QueueLengthStore, IProvideQueueLength> QueueLengthProviderBuilder(string connectionString, TransportCustomization transportCustomization)
        {
            return(qls =>
            {
                var queueLengthProvider = transportCustomization.CreateQueueLengthProvider();

                Action <QueueLengthEntry[], EndpointToQueueMapping> store = (es, q) => qls.Store(es.Select(e => ToEntry(e)).ToArray(), ToQueueId(q));

                queueLengthProvider.Initialize(connectionString, store);

                return queueLengthProvider;
            });
        }