static void Main(string[] args) { XmlConfigurator.Configure(new FileInfo("testsubscriber.log4net.xml")); var cfg = RunnerConfigurator.New(c => { c.SetServiceName("Test Subscriber"); c.SetDisplayName("Test Subscriber"); c.SetDescription("a Mass Transit test service for handling new customer orders."); c.RunAsLocalSystem(); c.DependencyOnMsmq(); c.BeforeStart(a => { }); c.ConfigureService <TestSubscriberService>(s => { s.CreateServiceLocator(() => { IWindsorContainer container = new DefaultMassTransitContainer("TestSubscriber.Castle.xml"); container.AddComponent <TestSubscriberService>(); container.AddComponent <Subscriber>(); return(ServiceLocator.Current); }); s.WhenStarted(o => o.Start()); s.WhenStopped(o => o.Stop()); }); }); Runner.Host(cfg, args); }
static void Main(string[] args) { XmlConfigurator.Configure(); ObjectFactory.Initialize(init => { init.AddRegistry(new TableReservationServiceRegistry()); }); var runner = RunnerConfigurator.New(cfg => { cfg.SetServiceName("tosca.tablereservation"); cfg.SetDisplayName("Tosca Table Reservation System"); cfg.SetDescription("Used to maximize table usage"); cfg.ConfigureService <TableReservationService>(sc => { sc.HowToBuildService(name => ObjectFactory.GetInstance <TableReservationService>()); sc.WhenStarted(s => s.Start()); sc.WhenStopped(s => s.Stop()); }); }); Runner.Host(runner, args); }
static void Main(string[] args) { BootstrapLogger(); MsmqEndpointConfigurator.Defaults(x => { x.CreateMissingQueues = true; }); ObjectFactory.Initialize(x => { x.For <IConfiguration>().Use <Configuration>(); }); var cfg = RunnerConfigurator.New(config => { config.SetServiceName(typeof(Program).Namespace); config.SetDisplayName(typeof(Program).Namespace); config.SetDescription("MassTransit Legacy Services"); config.RunAsLocalSystem(); config.DependencyOnMsmq(); config.DependencyOnMsSql(); config.ConfigureService <LegacySubscriptionProxyService>(s => { ConfigureService <LegacySubscriptionProxyService, LegacySupportRegistry>(s, start => start.Start(), stop => stop.Stop()); }); config.AfterStoppingTheHost(x => { _log.Info("MassTransit Legacy Services are exiting..."); }); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.xml")); var cfg = RunnerConfigurator.New(c => { c.SetServiceName("PostalService"); c.SetDisplayName("Sample Email Service"); c.SetDescription("we goin' postal"); c.RunAsLocalSystem(); c.DependencyOnMsmq(); c.BeforeStartingServices(a => { var container = new WindsorContainer("postal-castle.xml"); container.AddComponent <SendEmailConsumer>("sec"); container.AddComponent <PostalService>(); }); c.ConfigureService <PostalService>(a => { a.WhenStarted(o => o.Start()); a.WhenStopped(o => o.Stop()); }); }); Runner.Host(cfg, args); }
public void ConfigureService <T>(string[] args) where T : class, IServiceInterface { var cfg = RunnerConfigurator.New(c => { c.SetServiceName(ServiceName); c.SetDisplayName(DisplayName); c.SetDescription(Description); c.RunAsLocalSystem(); c.DependencyOnMsmq(); c.ConfigureService <T>(s => { MsmqEndpointConfigurator.Defaults(def => def.CreateMissingQueues = true); s.HowToBuildService(name => { Container container = new Container(x => { x.AddRegistry(new IocRegistry(SourceQueue, SubscriptionQueue)); ContainerSetup(x); }); return(container.GetInstance <T>()); }); s.WhenStarted(start => start.Start()); s.WhenStopped(stop => stop.Stop()); }); }); ObjectFactory.AssertConfigurationIsValid(); Runner.Host(cfg, args); }
private static void Main(string[] args) { XmlConfigurator.Configure(new FileInfo("cashier.log4net.xml")); RunConfiguration cfg = RunnerConfigurator.New(c => { c.SetServiceName("StarbucksCashier"); c.SetDisplayName("Starbucks Cashier"); c.SetDescription("a Mass Transit sample service for handling orders of coffee."); c.RunAsLocalSystem(); c.DependencyOnMsmq(); MsmqEndpointConfigurator.Defaults(x => { x.CreateMissingQueues = true; }); IWindsorContainer container = BootstrapContainer(); DisplayStateMachine(); c.ConfigureService <CashierService>(s => { s.HowToBuildService(builder => container.Resolve <CashierService>()); s.WhenStarted(o => o.Start()); s.WhenStopped(o => o.Stop()); }); }); Runner.Host(cfg, args); }
static void Main(string[] args) { var cfg = RunnerConfigurator.New(x => { x.AfterStoppingTheHost(h => { }); x.ConfigureService <Scheduler>(s => { s.Named("ZmanimScheduler"); s.HowToBuildService(name => new Scheduler()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); s.WhenPaused(tc => tc.Pause()); }); x.RunAsLocalSystem(); //x.RunAsFromInteractive(); x.SetDescription("ZmanimScheduler Host"); x.SetDisplayName("ZmanimScheduler"); x.SetServiceName("ZmanimScheduler"); }); Runner.Host(cfg, args); }
static void Main(string[] args) { string serviceName = "ExcelUpload Add Product Service"; var cfg = RunnerConfigurator.New(x => { x.ConfigureServiceInIsolation <HostService>("svc", s => { s.CreateServiceLocator(() => { ObjectFactory.Initialize(i => { i.ForConcreteType <HostService>().Configure.WithName("svc"); }); return(new StructureMapServiceLocator()); }); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); x.SetDisplayName(serviceName); x.SetServiceName("excelupload_addproduct"); x.SetDescription("Runs the Excel Upload Add Product Service (Batch processor)"); x.RunAsLocalSystem(); }); Runner.Host(cfg, args); }
public void A_service_configuration() { _runConfiguration = RunnerConfigurator.New(x => { x.SetDisplayName("chris"); x.SetServiceName("chris"); x.SetDescription("chris's pants"); x.ConfigureService <TestService>(c => { c.WhenStarted(s => s.Start()); c.WhenStopped(s => s.Stop()); c.WhenPaused(s => { }); c.WhenContinued(s => { }); c.Named("my_service"); }); x.DoNotStartAutomatically(); x.RunAs("dru", "pass"); x.DependsOn("ServiceName"); x.DependencyOnMsmq(); x.DependencyOnMsSql(); x.BeforeInstall(() => { }); x.AfterInstall(() => { }); x.BeforeUninstall(() => { }); x.AfterUninstall(() => { }); }); }
static void Main(string[] args) { XmlConfigurator.Configure(new FileInfo("MockShipMessagePublisher.log4net.xml")); var cfg = RunnerConfigurator.New(c => { c.SetServiceName("Mock Shipping Msg Service"); c.SetDisplayName("Mock Shipping Msg Service"); c.SetDescription("a service for faking shipping messages and Publishing the corresponding events on the Bus."); c.DependencyOnMsmq(); c.RunAsFromInteractive(); //Is this right? c.BeforeStart(a => { }); c.ConfigureService <ShippingMessageService>(s => { s.CreateServiceLocator(() => { IWindsorContainer container = new DefaultMassTransitContainer("MockShipMessagePublisher.Castle.xml"); Container.InitializeWith(container); Environment.Setup(); container.AddComponent <ShippingMessageService>(); return(ServiceLocator.Current); }); s.WhenStarted(o => o.Start()); s.WhenStopped(o => o.Stop()); }); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { BootstrapLogger(); MsmqEndpointConfigurator.Defaults(x => { x.CreateMissingQueues = true; }); var configuration = RunnerConfigurator.New(config => { config.SetServiceName(typeof(Program).Namespace); config.SetDisplayName(typeof(Program).Namespace); config.SetDescription(typeof(Program).Namespace); config.RunAsLocalSystem(); config.DependencyOnMsmq(); config.DependencyOnMsSql(); ObjectFactory.Configure(x => { x.AddRegistry(new GatewayServiceRegistry()); }); config.ConfigureService <OrderServiceGateway>(typeof(OrderServiceGateway).Name, service => { service.CreateServiceLocator(() => new StructureMapObjectBuilder(ObjectFactory.Container)); service.WhenStarted(x => x.Start()); service.WhenStopped(x => x.Stop()); }); config.AfterStoppingTheHost(x => { _log.Info("Exiting..."); }); }); Runner.Host(configuration, args); }
/// <summary> /// Main. /// </summary> /// <param name="args"></param> public static void Main(string[] args) { RunConfiguration cfg = RunnerConfigurator.New(x => { x.ConfigureService <QuartzServer>(s => { s.Named(Configuration.ServiceName); s.HowToBuildService(builder => new QuartzServer()); s.WhenStarted(server => { XafApplication xafApplication = XafApplicationFactory.GetApplication(ConfigurationManager.AppSettings["xafApplicationPath"]); server.Initialize(xafApplication); server.Start(); }); s.WhenPaused(server => server.Pause()); s.WhenContinued(server => server.Resume()); s.WhenStopped(server => server.Stop()); }); x.SetEventTimeout(TimeSpan.FromMinutes(2)); x.RunAsLocalSystem(); x.SetDescription(Configuration.ServiceDescription); x.SetDisplayName(Configuration.ServiceDisplayName); x.SetServiceName(Configuration.ServiceName); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { _log.Info("InternalInventoryService Loading..."); var cfg = RunnerConfigurator.New(c => { c.SetServiceName("InternalInventoryService"); c.SetDisplayName("Internal Inventory Service"); c.SetDescription("Handles inventory for internal systems"); c.RunAsLocalSystem(); c.DependencyOnMsmq(); c.BeforeStartingServices(a => { var container = new DefaultMassTransitContainer("InternalInventoryService.Castle.xml"); container.AddComponent <InventoryLevelService>(); container.AddComponent <InternalInventoryServiceLifeCycle>(typeof(InternalInventoryServiceLifeCycle).Name); _container = container; }); c.ConfigureService <InternalInventoryServiceLifeCycle>(s => { s.HowToBuildService(name => _container.Resolve <InternalInventoryServiceLifeCycle>()); s.WhenStarted(o => o.Start()); s.WhenStopped(o => o.Stop()); }); }); Runner.Host(cfg, args); }
/// <summary> /// Main. /// </summary> /// <param name="args"></param> public static void Main(string[] args) { RunConfiguration cfg = RunnerConfigurator.New(x => { x.ConfigureService <QuartzServer>(s => { s.Named("quartz.server"); s.HowToBuildService(builder => { QuartzServer server = new QuartzServer(); server.Initialize(); return(server); }); s.WhenStarted(server => server.Start()); s.WhenPaused(server => server.Pause()); s.WhenContinued(server => server.Resume()); s.WhenStopped(server => server.Stop()); }); x.RunAsLocalSystem(); x.SetDescription(Configuration.ServiceDescription); x.SetDisplayName(Configuration.ServiceDisplayName); x.SetServiceName(Configuration.ServiceName); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { _log.Info("Server Loading"); var cfg = RunnerConfigurator.New(c => { c.SetServiceName("SampleClientService"); c.SetDisplayName("SampleClientService"); c.SetDescription("SampleClientService"); c.DependencyOnMsmq(); c.RunAsLocalSystem(); c.ConfigureService <ClientService>(typeof(ClientService).Name, s => { s.WhenStarted(o => { var bus = ServiceBusConfigurator.New(servicesBus => { servicesBus.ReceiveFrom("msmq://localhost/mt_client"); servicesBus.ConfigureService <SubscriptionClientConfigurator>(client => { // need to add the ability to read from configuratino settings somehow client.SetSubscriptionServiceEndpoint("msmq://localhost/mt_subscriptions"); }); }); o.Start(bus); }); s.WhenStopped(o => o.Stop()); s.CreateServiceLocator(() => { var container = new DefaultMassTransitContainer(); IEndpointFactory endpointFactory = EndpointFactoryConfigurator.New(e => { e.SetObjectBuilder(ServiceLocator.Current.GetInstance <IObjectBuilder>()); e.RegisterTransport <MsmqEndpoint>(); }); container.Kernel.AddComponentInstance("endpointFactory", typeof(IEndpointFactory), endpointFactory); container.AddComponent <ClientService>(typeof(ClientService).Name); container.AddComponent <PasswordUpdater>(); return(ServiceLocator.Current); //set in the DefaultMTContainer }); }); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { _log.Info("subscription_mgr Loading..."); Console.WriteLine("MSMQ Subscription Service"); var cfg = RunnerConfigurator.New(c => { c.SetServiceName("subscription_mgr"); c.SetDisplayName("Subscription Service"); c.SetDescription("Coordinates subscriptions between multiple systems"); c.DependencyOnMsmq(); c.RunAsLocalSystem(); c.BeforeStartingServices(s => { var container = new DefaultMassTransitContainer(); IEndpointFactory endpointFactory = EndpointFactoryConfigurator.New(e => { e.SetObjectBuilder(container.Resolve <IObjectBuilder>()); e.RegisterTransport <MsmqEndpoint>(); }); container.Kernel.AddComponentInstance("endpointFactory", typeof(IEndpointFactory), endpointFactory); _wob = new WindsorObjectBuilder(container.Kernel); ServiceLocator.SetLocatorProvider(() => _wob); }); c.ConfigureService <SubscriptionService>(ConfigureSubscriptionService); c.ConfigureService <TimeoutService>(ConfigureTimeoutService); c.ConfigureService <HealthService>(ConfigureHealthService); }); try { Runner.Host(cfg, args); } catch (Exception ex) { Console.WriteLine("Error trying to run service: " + ex); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } }
private static void Main(string[] args) { BootstrapLogger(); MsmqEndpointConfigurator.Defaults(x => { x.CreateMissingQueues = true; }); ObjectFactory.Initialize(x => { x.For <IConfiguration>().Use <Configuration>(); }); var serviceConfiguration = ObjectFactory.GetInstance <IConfiguration>(); RunConfiguration configuration = RunnerConfigurator.New(config => { config.SetServiceName(typeof(Program).Namespace); config.SetDisplayName(typeof(Program).Namespace); config.SetDescription("MassTransit Runtime Services (Subscription, Timeout, Health Monitoring)"); if (serviceConfiguration.UseServiceCredentials) { config.RunAs(serviceConfiguration.ServiceUsername, serviceConfiguration.ServicePassword); } else { config.RunAsLocalSystem(); } config.DependencyOnMsmq(); if (serviceConfiguration.SubscriptionServiceEnabled) { config.ConfigureService <SubscriptionService>(service => { ConfigureService <SubscriptionService, SubscriptionServiceRegistry>(service, start => start.Start(), stop => stop.Stop()); }); } if (serviceConfiguration.HealthServiceEnabled) { config.ConfigureService <HealthService>(service => { ConfigureService <HealthService, HealthServiceRegistry>(service, start => start.Start(), stop => stop.Stop()); }); } if (serviceConfiguration.TimeoutServiceEnabled) { config.ConfigureService <TimeoutService>(service => { ConfigureService <TimeoutService, TimeoutServiceRegistry>(service, start => start.Start(), stop => stop.Stop()); }); } config.AfterStoppingTheHost(x => { _log.Info("MassTransit Runtime Services are exiting..."); }); }); Runner.Host(configuration, args); }
static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("client.log4net.xml")); _log.Info("Client Loading"); WindsorContainer container; RunConfiguration cfg = RunnerConfigurator.New(c => { c.SetServiceName("SampleClientService"); c.SetDisplayName("SampleClientService"); c.SetDescription("SampleClientService"); c.DependencyOnMsmq(); c.RunAsLocalSystem(); c.ConfigureService <ClientService>(s => { string serviceName = typeof(ClientService).Name; s.Named(serviceName); s.WhenStarted(o => { container = new WindsorContainer(); container.Register(Component.For <PasswordUpdater>()); Bus.Initialize(sbc => { sbc.ReceiveFrom("msmq://localhost/mt_client"); sbc.UseSubscriptionService("msmq://localhost/mt_subscriptions"); sbc.UseMsmq(); sbc.VerifyMsDtcConfiguration(); sbc.VerifyMsmqConfiguration(); }); var bus = Bus.Instance; o.Start(bus); }); s.WhenStopped(o => o.Stop()); s.HowToBuildService(name => new ClientService()); }); }); Runner.Host(cfg, args); }
public void EstablishContext() { _configuration = RunnerConfigurator.New(x => { x.SetDescription("topshelf test installation"); x.SetDisplayName("TOPSHELF-TEST"); x.SetServiceName("TOPSHELF-TEST"); x.RunAsLocalSystem(); x.ConfigureService <TestInstall>(s => { s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); }); }
static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("server.log4net.xml")); WindsorContainer container; _log.Info("Server Loading"); RunConfiguration cfg = RunnerConfigurator.New(c => { c.SetServiceName("SampleService"); c.SetServiceName("Sample Service"); c.SetServiceName("Something"); c.DependencyOnMsmq(); c.RunAsLocalSystem(); c.ConfigureService <PasswordUpdateService>(s => { string serviceName = typeof(PasswordUpdateService).Name; s.Named(serviceName); s.WhenStarted(o => { container = new WindsorContainer(); //load up consumers? Bus.Initialize(sbc => { sbc.UseMsmq(); sbc.VerifyMsDtcConfiguration(); sbc.VerifyMsmqConfiguration(); sbc.ReceiveFrom("msmq://localhost/mt_server"); sbc.UseSubscriptionService("msmq://localhost/mt_subscriptions"); }); var bus = Bus.Instance; o.Start(bus); }); s.WhenStopped(o => o.Stop()); s.HowToBuildService(name => new PasswordUpdateService()); }); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("server.log4net.xml")); _log.Info("Server Loading"); IRunConfiguration cfg = RunnerConfigurator.New(c => { c.SetServiceName("SampleService"); c.SetServiceName("Sample Service"); c.SetServiceName("Something"); c.DependencyOnMsmq(); c.RunAsLocalSystem(); c.ConfigureService <PasswordUpdateService>(typeof(PasswordUpdateService).Name, s => { s.WhenStarted(o => { IServiceBus bus = ServiceBusConfigurator.New(x => { x.ReceiveFrom("msmq://localhost/mt_server"); x.ConfigureService <SubscriptionClientConfigurator>(b => { b.SetSubscriptionServiceEndpoint("msmq://localhost/mt_subscriptions"); }); }); o.Start(bus); }); s.WhenStopped(o => o.Stop()); s.CreateServiceLocator(() => { var container = new DefaultMassTransitContainer(); IEndpointFactory endpointFactory = EndpointFactoryConfigurator .New(x => { x.SetObjectBuilder(ServiceLocator.Current.GetInstance <IObjectBuilder>()); x.RegisterTransport <MsmqEndpoint>(); }); container.Kernel.AddComponentInstance("endpointFactory", typeof(IEndpointFactory), endpointFactory); container.AddComponent <PasswordUpdateService>(typeof(PasswordUpdateService).Name); return(ServiceLocator.Current); //set in DefaultMTContainer }); }); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { XmlConfigurator.Configure(); var cfg = RunnerConfigurator.New(c => { c.RunAsLocalSystem(); c.SetServiceName("audit"); c.SetDisplayName("audit"); c.SetDescription("audit"); c.BeforeStartingServices(a => { var container = new DefaultMassTransitContainer("audit-castle.config"); Configuration _cfg = new Configuration().Configure(); _cfg.AddAssembly(typeof(NHibernateRepositoryFactory).Assembly); ISessionFactory _sessionFactory = _cfg.BuildSessionFactory(); LocalContext.Current.Store(_sessionFactory); NHibernateUnitOfWork.SetSessionProvider(_sessionFactory.OpenSession); UnitOfWork.SetUnitOfWorkProvider(NHibernateUnitOfWork.Create); container.AddComponent <ISagaRepository <RegisterUserSaga>, NHibernateSagaRepository <RegisterUserSaga> >(); container.AddComponent <Responder>(); container.AddComponent <RegisterUserSaga>(); container.AddComponent <AuditService>(typeof(AuditService).Name); }); c.ConfigureService <AuditService>(a => { a.WhenStarted(o => o.Start()); a.WhenStopped(o => o.Stop()); }); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { XmlConfigurator.Configure(new FileInfo("MockOrder.log4net.xml")); var cfg = RunnerConfigurator.New(c => { c.SetServiceName("MockOrderSubscriber"); c.SetDisplayName("MockOrderSubscriber"); c.SetDescription("a service for mocking up order processing."); c.DependencyOnMsmq(); c.RunAsLocalSystem(); c.BeforeStart(a => { }); c.ConfigureService <MockOrderService>(s => { s.CreateServiceLocator(() => { IWindsorContainer container = new DefaultMassTransitContainer("MockOrder.Castle.xml"); Container.InitializeWith(container); Environment.Setup(); container.AddComponent <MockOrderService>(); container.AddComponent <Subscriber <CreateOrderMessage> >(); //var builder = new WindsorObjectBuilder(container.Kernel); //ServiceLocator.SetLocatorProvider(() => builder); return(ServiceLocator.Current); }); s.WhenStarted(o => o.Start()); s.WhenStopped(o => o.Stop()); }); }); Runner.Host(cfg, args); }
private static void Main(string[] args) { _log.Info("SubscriptionManagerGUI Loading..."); var cfg = RunnerConfigurator.New(x => { x.SetServiceName("SubscriptionManagerGUI"); x.SetDisplayName("Sample GUI Subscription Service"); x.SetDescription("Coordinates subscriptions between multiple systems"); x.DependencyOnMsmq(); x.RunAsLocalSystem(); x.UseWinFormHost <SubscriptionManagerForm>(); x.BeforeStart(s => { var container = new DefaultMassTransitContainer(); IEndpointFactory endpointFactory = EndpointFactoryConfigurator.New(e => { e.SetObjectBuilder(container.Resolve <IObjectBuilder>()); e.RegisterTransport <MsmqEndpoint>(); }); container.Kernel.AddComponentInstance("endpointFactory", typeof(IEndpointFactory), endpointFactory); container.AddComponent <SubscriptionManagerForm>(); var wob = new WindsorObjectBuilder(container.Kernel); ServiceLocator.SetLocatorProvider(() => wob); }); x.ConfigureService <SubscriptionService>(ConfigureSubscriptionService); x.ConfigureService <TimeoutService>(ConfigureTimeoutService); x.ConfigureService <HealthService>(ConfigureHealthService); }); Runner.Host(cfg, args); }
public void ConfigureService <T>(string[] args) where T : class, IServiceInterface { IRunConfiguration cfg = RunnerConfigurator.New(c => { c.SetServiceName(ServiceName); c.SetDisplayName(DisplayName); c.SetDescription(Description); c.RunAsLocalSystem(); c.DependencyOnMsmq(); c.ConfigureService <T>(typeof(T).Name, s => { MsmqEndpointConfigurator.Defaults(def => def.CreateMissingQueues = true); s.CreateServiceLocator(() => { Container container = new Container(x => { x.AddRegistry(new IocRegistry(SourceQueue, SubscriptionQueue)); ContainerSetup(x); }); IServiceLocator objectBuilder = new StructureMapObjectBuilder(container); ServiceLocator.SetLocatorProvider(() => objectBuilder); return(objectBuilder); }); s.WhenStarted(start => start.Start()); s.WhenStopped(stop => stop.Stop()); }); }); ObjectFactory.AssertConfigurationIsValid(); Runner.Host(cfg, args); }
static void Main(string[] args) { var arguments = new HostArguments(args); if (arguments.Help) { arguments.PrintUsage(); return; } assemblyScannerResults = AssemblyScanner.GetScannableAssemblies(); var endpointTypeDeterminer = new EndpointTypeDeterminer(assemblyScannerResults, () => ConfigurationManager.AppSettings["EndpointConfigurationType"]); var endpointConfigurationType = endpointTypeDeterminer.GetEndpointConfigurationTypeForHostedEndpoint(arguments); var endpointConfigurationFile = endpointConfigurationType.EndpointConfigurationFile; var endpointName = endpointConfigurationType.EndpointName; var serviceName = endpointConfigurationType.ServiceName; var endpointVersion = endpointConfigurationType.EndpointVersion; var displayName = serviceName + "-" + endpointVersion; if (arguments.SideBySide) { serviceName += "-" + endpointVersion; } //Add the endpoint name so that the new appdomain can get it if (arguments.EndpointName == null && !String.IsNullOrEmpty(endpointName)) { args = args.Concat(new[] { String.Format(@"/endpointName={0}", endpointName) }).ToArray(); } //Add the ScannedAssemblies name so that the new appdomain can get it if (arguments.ScannedAssemblies.Count == 0) { args = assemblyScannerResults.Assemblies.Select(s => s.ToString()).Aggregate(args, (current, result) => current.Concat(new[] { String.Format(@"/scannedAssemblies={0}", result) }).ToArray()); } //Add the endpointConfigurationType name so that the new appdomain can get it if (arguments.EndpointConfigurationType == null) { args = args.Concat(new[] { String.Format(@"/endpointConfigurationType={0}", endpointConfigurationType.AssemblyQualifiedName) }).ToArray(); } if (arguments.Install) { WindowsInstaller.Install(args, endpointConfigurationFile); } IRunConfiguration cfg = RunnerConfigurator.New(x => { x.ConfigureServiceInIsolation <WindowsHost>(endpointConfigurationType.AssemblyQualifiedName, c => { c.ConfigurationFile(endpointConfigurationFile); c.WhenStarted(service => service.Start()); c.WhenStopped(service => service.Stop()); c.CommandLineArguments(args, () => SetHostServiceLocatorArgs); c.CreateServiceLocator(() => new HostServiceLocator()); }); if (arguments.Username != null && arguments.Password != null) { x.RunAs(arguments.Username, arguments.Password); } else { x.RunAsLocalSystem(); } if (arguments.StartManually) { x.DoNotStartAutomatically(); } x.SetDisplayName(arguments.DisplayName ?? displayName); x.SetServiceName(serviceName); x.SetDescription(arguments.Description ?? string.Format("NServiceBus Endpoint Host Service for {0}", displayName)); var serviceCommandLine = new List <string>(); if (!String.IsNullOrEmpty(arguments.EndpointConfigurationType)) { serviceCommandLine.Add(String.Format(@"/endpointConfigurationType:""{0}""", arguments.EndpointConfigurationType)); } if (!String.IsNullOrEmpty(endpointName)) { serviceCommandLine.Add(String.Format(@"/endpointName:""{0}""", endpointName)); } if (!String.IsNullOrEmpty(serviceName)) { serviceCommandLine.Add(String.Format(@"/serviceName:""{0}""", serviceName)); } if (arguments.ScannedAssemblies.Count > 0) { serviceCommandLine.AddRange(arguments.ScannedAssemblies.Select(assembly => String.Format(@"/scannedAssemblies:""{0}""", assembly))); } if (arguments.OtherArgs.Any()) { serviceCommandLine.AddRange(arguments.OtherArgs); } var commandLine = String.Join(" ", serviceCommandLine); x.SetServiceCommandLine(commandLine); if (arguments.DependsOn == null) { x.DependencyOnMsmq(); } else { foreach (var dependency in arguments.DependsOn) { x.DependsOn(dependency); } } }); try { Runner.Host(cfg, args); } catch (StateMachineException exception) { var innerException = exception.InnerException; innerException.PreserveStackTrace(); throw innerException; } }
private static void Main(string[] args) { var commandLineArguments = Parser.ParseArgs(args); var arguments = new HostArguments(commandLineArguments); if (arguments.Help != null) { DisplayHelpContent(); return; } var endpointConfigurationType = GetEndpointConfigurationType(arguments); AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType); var endpointConfigurationFile = GetEndpointConfigurationFile(endpointConfigurationType); var endpointConfiguration = Activator.CreateInstance(endpointConfigurationType); EndpointId = GetEndpointId(endpointConfiguration); AppDomain.CurrentDomain.SetupInformation.AppDomainInitializerArguments = args; var cfg = RunnerConfigurator.New(x => { x.ConfigureServiceInIsolation <WindowsHost>(endpointConfigurationType.AssemblyQualifiedName, c => { c.ConfigurationFile(endpointConfigurationFile); c.CommandLineArguments(args, () => SetHostServiceLocatorArgs); c.WhenStarted(service => service.Start()); c.WhenStopped(service => service.Stop()); c.CreateServiceLocator(() => new HostServiceLocator()); }); if (arguments.Username != null && arguments.Password != null) { x.RunAs(arguments.Username.Value, arguments.Password.Value); } else { x.RunAsLocalSystem(); } if (arguments.StartManually != null) { x.DoNotStartAutomatically(); } x.SetDisplayName(arguments.DisplayName != null ? arguments.DisplayName.Value : EndpointId); x.SetServiceName(arguments.ServiceName != null ? arguments.ServiceName.Value : EndpointId); x.SetDescription(arguments.Description != null ? arguments.Description.Value : "NServiceBus Message Endpoint Host Service"); x.DependencyOnMsmq(); var serviceCommandLine = commandLineArguments.CustomArguments.AsCommandLine(); if (arguments.ServiceName != null) { serviceCommandLine += " /serviceName:\"" + arguments.ServiceName.Value + "\""; } x.SetServiceCommandLine(serviceCommandLine); if (arguments.DependsOn != null) { var dependencies = arguments.DependsOn.Value.Split(','); foreach (var dependency in dependencies) { if (dependency.ToUpper() == KnownServiceNames.Msmq) { continue; } x.DependsOn(dependency); } } }); Runner.Host(cfg, args); }
static void Main(string[] args) { Parser.Args commandLineArguments = Parser.ParseArgs(args); var arguments = new HostArguments(commandLineArguments); if (arguments.Help != null) { DisplayHelpContent(); return; } var endpointConfigurationType = GetEndpointConfigurationType(arguments); AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType); string endpointConfigurationFile = GetEndpointConfigurationFile(endpointConfigurationType); var endpointName = GetEndpointName(endpointConfigurationType); var endpointVersion = GetEndpointVersion(endpointConfigurationType); if (arguments.ServiceName != null) { endpointName = arguments.ServiceName.Value; } var serviceName = endpointName; var displayName = serviceName + "-" + endpointVersion; //add the endpoint name so that the new appdomain can get it args = args.Concat(new[] { endpointName }).ToArray(); AppDomain.CurrentDomain.SetupInformation.AppDomainInitializerArguments = args; if (commandLineArguments.Install) { WindowsInstaller.Install(args, endpointConfigurationType, endpointName, endpointConfigurationFile); } IRunConfiguration cfg = RunnerConfigurator.New(x => { x.ConfigureServiceInIsolation <WindowsHost>(endpointConfigurationType.AssemblyQualifiedName, c => { c.ConfigurationFile(endpointConfigurationFile); c.CommandLineArguments(args, () => SetHostServiceLocatorArgs); c.WhenStarted(service => service.Start()); c.WhenStopped(service => service.Stop()); c.CreateServiceLocator(() => new HostServiceLocator()); }); if (arguments.Username != null && arguments.Password != null) { x.RunAs(arguments.Username.Value, arguments.Password.Value); } else { x.RunAsLocalSystem(); } if (arguments.StartManually != null) { x.DoNotStartAutomatically(); } x.SetDisplayName(arguments.DisplayName != null ? arguments.DisplayName.Value : displayName); x.SetServiceName(serviceName); x.SetDescription(arguments.Description != null ? arguments.Description.Value : "NServiceBus Message Endpoint Host Service for " + displayName); var serviceCommandLine = commandLineArguments.CustomArguments.AsCommandLine(); serviceCommandLine += " /serviceName:\"" + serviceName + "\""; x.SetServiceCommandLine(serviceCommandLine); if (arguments.DependsOn == null) { x.DependencyOnMsmq(); } else { foreach (var dependency in arguments.DependsOn.Value.Split(',')) { x.DependsOn(dependency); } } }); Runner.Host(cfg, args); }
static void Main(string[] args) { Parser.Args commandLineArguments = Parser.ParseArgs(args); var arguments = new HostArguments(commandLineArguments); if (arguments.Help != null) { DisplayHelpContent(); return; } var endpointConfigurationType = GetEndpointConfigurationType(arguments); if (endpointConfigurationType == null) { if (arguments.InstallInfrastructure == null) { throw new InvalidOperationException("No endpoint configuration found in scanned assemblies. " + "This usually happens when NServiceBus fails to load your assembly containing IConfigureThisEndpoint." + " Try specifying the type explicitly in the NServiceBus.Host.exe.config using the appsetting key: EndpointConfigurationType, " + "Scanned path: " + AppDomain.CurrentDomain.BaseDirectory); } Console.WriteLine("Running infrastructure installers and exiting (ignoring other command line parameters if exist)."); InstallInfrastructure(); return; } AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType); string endpointConfigurationFile = GetEndpointConfigurationFile(endpointConfigurationType); var endpointName = GetEndpointName(endpointConfigurationType, arguments); var endpointVersion = GetEndpointVersion(endpointConfigurationType); var serviceName = endpointName; if (arguments.ServiceName != null) { serviceName = arguments.ServiceName.Value; } var displayName = serviceName + "-" + endpointVersion; if (arguments.SideBySide != null) { serviceName += "-" + endpointVersion; displayName += " (SideBySide)"; } //add the endpoint name so that the new appdomain can get it args = args.Concat(new[] { endpointName }).ToArray(); AppDomain.CurrentDomain.SetupInformation.AppDomainInitializerArguments = args; if ((commandLineArguments.Install) || (arguments.InstallInfrastructure != null)) { WindowsInstaller.Install(args, endpointConfigurationType, endpointName, endpointConfigurationFile, commandLineArguments.Install, arguments.InstallInfrastructure != null); } IRunConfiguration cfg = RunnerConfigurator.New(x => { x.ConfigureServiceInIsolation <WindowsHost>(endpointConfigurationType.AssemblyQualifiedName, c => { c.ConfigurationFile(endpointConfigurationFile); c.CommandLineArguments(args, () => SetHostServiceLocatorArgs); c.WhenStarted(service => service.Start()); c.WhenStopped(service => service.Stop()); c.CreateServiceLocator(() => new HostServiceLocator()); }); if (arguments.Username != null && arguments.Password != null) { x.RunAs(arguments.Username.Value, arguments.Password.Value); } else { x.RunAsLocalSystem(); } if (arguments.StartManually != null) { x.DoNotStartAutomatically(); } x.SetDisplayName(arguments.DisplayName != null ? arguments.DisplayName.Value : displayName); x.SetServiceName(serviceName); x.SetDescription(arguments.Description != null ? arguments.Description.Value : "NServiceBus Message Endpoint Host Service for " + displayName); var serviceCommandLine = commandLineArguments.CustomArguments.AsCommandLine(); serviceCommandLine += " /serviceName:\"" + serviceName + "\""; serviceCommandLine += " /endpointName:\"" + endpointName + "\""; x.SetServiceCommandLine(serviceCommandLine); if (arguments.DependsOn == null) { x.DependencyOnMsmq(); } else { foreach (var dependency in arguments.DependsOn.Value.Split(',')) { x.DependsOn(dependency); } } }); Runner.Host(cfg, args); }
static void Main(string[] args) { XmlConfigurator.Configure(); var serviceName = ConfigurationManager.AppSettings["ServiceName"].IfNullOrEmpty("Concentrator Service Host"); AppDomain.CurrentDomain.AssemblyResolve += (sender, arguments) => { var pluginDirectory = ConfigurationManager.AppSettings["PluginPath"]; if (!Directory.Exists(pluginDirectory)) { throw new IOException(String.Format("'{0}' does not exist.", pluginDirectory)); } var assemblyName = new AssemblyName(arguments.Name); var fullName = Path.Combine(pluginDirectory, assemblyName.Name + ".dll"); if (!File.Exists(fullName)) { throw new IOException(String.Format("'{0}' does not exist.", fullName)); } return(Assembly.LoadFile(fullName)); }; #if DEBUG IKernel kernel = new ConcentratorKernel(new ManagementServiceModule(), new ContextThreadScopeModule(), new ThreadScopeUnitOfWorkModule(), new UnsecuredRepositoryModule(), new ServiceModule()); var locator = new NinjectServiceLocator(kernel); ServiceLocator.SetLocatorProvider(() => locator); if (args.Length > 0) { ServiceLayer.Start(args[0].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray().Select(c => int.Parse(c)).ToArray()); } else { ServiceLayer.Start(); } Console.ReadLine(); ServiceLayer.Stop(); #else RunConfiguration cfg = RunnerConfigurator.New(x => { IKernel kernel = new ConcentratorKernel(new ManagementServiceModule(), new ContextThreadScopeModule(), new ThreadScopeUnitOfWorkModule(), new UnsecuredRepositoryModule(), new ServiceModule()); var locator = new NinjectServiceLocator(kernel); ServiceLocator.SetLocatorProvider(() => locator); x.ConfigureService <ServiceLayer>(s => { s.Named("tc"); s.HowToBuildService(name => ServiceLayer.Instance); s.WhenStarted(tc => ServiceLayer.Start()); s.WhenStopped(tc => ServiceLayer.Stop()); }); x.SetDescription("Concentrator Host Process for running plugins"); x.SetDisplayName(serviceName); //staging x.SetServiceName(serviceName); //staging x.RunAsLocalSystem(); // } }); Runner.Host(cfg, args); #endif }