public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSerilog() .RegisterApplicationServices() .ConfigureNSBEndpointWithDefaults(x => HostedEndpointConfig.ReadFrom(x.Configuration)) .ConfigureServices(services => services.AddHostedService <ChatlistenerWorker>()) .UseWindowsService();
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSerilog() .UseNServiceBus(context => { var config = HostedEndpointConfig.ReadFrom(context.Configuration); var builder = new EndpointBuilder(config); builder.ConfigureRouting(routing => { routing.RouteToEndpoint(typeof(LeaveChannelCommand), "AntiHarassmentChatlistener"); routing.RouteToEndpoint(typeof(JoinChannelCommand), "AntiHarassmentChatlistener"); routing.RouteToEndpoint(typeof(SendAccountConfirmationCommand), "AntiHarassmentChatlistener"); routing.RouteToEndpoint(typeof(SendPasswordResetTokenCommand), "AntiHarassmentChatlistener"); routing.RouteToEndpoint(typeof(RuleExceedCheckCommand), "AntiHarassmentChatlistener"); }); return(builder.BuildConfiguration()); }) .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup <Startup>());
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseNServiceBus(context => { var config = HostedEndpointConfig.ReadFrom(context.Configuration); var builder = new EndpointBuilder(config); builder.ConfigureRouting(routing => { routing.RouteToEndpoint(typeof(CheckDataFeedCommand), "AntiHarassmentChatlistener"); routing.RouteToEndpoint(typeof(TrainSystemCommand), "AntiHarassmentChatlistener"); routing.RouteToEndpoint(typeof(LeaveChannelCommand), "AntiHarassmentChatlistener"); routing.RouteToEndpoint(typeof(JoinChannelCommand), "AntiHarassmentChatlistener"); }); return(builder.BuildConfiguration()); }) .ConfigureServices((_, services) => { services.AddSingleton <IMessageDispatcher, MessageDispatcher>(); services.AddHostedService <Worker>(); });