static void Main() { HostFactory.Run(configurator => { var container = new IocContainer(t => t.NameInCSharp()); var eventSubscriptionConfig = EventStoreSubscriptionConfiguration.FromAppConfig(); var eventStoreUrl = EventStoreUrl.Parse(eventSubscriptionConfig.Url); var eventStoreUserCredentials = EventStoreUserCredentials.Parse( eventSubscriptionConfig.UserCredentials.User, eventSubscriptionConfig.UserCredentials.Password); var eventTypeResolution = EventTypeFromNameResolver.FromTypesFromAssemblyContaining <NewRiskItemMapped>(); var eventStoreEndpoint = EventStoreEndpoint .OnUrl(eventStoreUrl) .WithCredentials(eventStoreUserCredentials) .WithEventTypeFromNameResolution(eventTypeResolution); var eventStoreSubscriptionEndpoint = EventStoreSubscriptionEndpoint .ListenTo(eventStoreUrl) .WithCredentials(eventStoreUserCredentials) .WithEventTypeFromNameResolution(eventTypeResolution) .WithSqlDatabaseEventIndexStorage(); Bootstrap.Application() .ResolveReferencesWith(container) .SetupDataConnectivity().WithSqlConnection() .SetupMessaging() .ConfigureSagas().WithDatabasePersistence() .ConfigureEventStoreEndpoint(eventStoreEndpoint) .ConfigureReceivingEndpoint(eventStoreSubscriptionEndpoint) .ConfigureMessageRouting().WireUpRouting() .Initialise(); Trace.TraceInformation( "Data warehouse service has started up and the types registered into the container are {0}{1}", Environment.NewLine, container.Describe()); configurator.Service <DataWarehouseController>(s => { s.ConstructUsing(name => container.Resolve <DataWarehouseController>()); s.WhenStarted(c => c.Start()); s.WhenStopped(c => c.Stop()); }); configurator.RunAsLocalSystem(); configurator.SetDescription("Applied Systems Data Warehouse Service"); configurator.SetDisplayName("Applied Systems Data Warehouse Service"); configurator.SetServiceName("Applied Systems Data Warehouse Service"); }); }
static void Main() { var config = RiskCaptureConfiguration.FromAppConfig(); var eventStorageConfig = EventStoreMessageStorageConfiguration.FromAppConfig(); var eventStoreEndpoint = EventStoreEndpoint .OnUrl(EventStoreUrl.Parse(eventStorageConfig.Url)) .WithCredentials( EventStoreUserCredentials.Parse( eventStorageConfig.UserCredentials.User, eventStorageConfig.UserCredentials.Password)) .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <NewRiskItemMapped>()); HostFactory.Run(configurator => { var container = new IocContainer(t => t.NameInCSharp()); Bootstrap.Application() .ResolveReferencesWith(container) .ConfigureRiskCapture() .SetupMessaging() .ConfigureEventStoreEndpoint(eventStoreEndpoint) .ConfigureMessageRouting().WireUpRouting() .Initialise(); Trace.TraceInformation( "Risk Capture service has started up and the types registered into the container are {0}{1}", Environment.NewLine, container.Describe()); configurator.Service <RiskCaptureController>(s => { s.ConstructUsing(name => new RiskCaptureController(config.Url, container.Resolve <IMessageReceiver>())); s.WhenStarted(c => c.Start()); s.WhenStopped(c => c.Stop()); }); configurator.RunAsLocalSystem(); configurator.SetDescription("Applied Systems Risk Capture Service"); configurator.SetDisplayName("Applied Systems Risk Capture Service"); configurator.SetServiceName("Applied Systems Risk Capture Service"); }); }