public void ConfigureContainer(IServiceProvider serviceProvider, Container container) { container.Register <StartBusModuleHandler>(); container.RegisterSingleton <IPowershellEngine, PowershellEngine>(); container.RegisterSingleton <IVirtualMachineInfoProvider, VirtualMachineInfoProvider>(); container.Collection.Register(typeof(IHandleMessages <>), typeof(VmHostAgentModule).Assembly); container.Collection.Append(typeof(IHandleMessages <>), typeof(IncomingOperationHandler <>)); container.ConfigureRebus(configurer => configurer .Transport(t => serviceProvider.GetService <IRebusTransportConfigurer>().Configure(t, $"{QueueNames.VMHostAgent}.{Environment.MachineName}")) .Routing(x => x.TypeBased() .Map(MessageTypes.ByRecipient(MessageRecipient.Controllers), QueueNames.Controllers) ) .Options(x => { x.SimpleRetryStrategy(); x.SetNumberOfWorkers(5); x.EnableSynchronousRequestReply(); }) .Subscriptions(s => serviceProvider.GetService <IRebusSubscriptionConfigurer>()?.Configure(s)) .Serialization(x => x.UseNewtonsoftJson(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None })) .Logging(x => x.ColoredConsole(LogLevel.Debug)).Start()); }
public void ConfigureContainer(IServiceProvider serviceProvider, Container container) { container.Register <StartBusModuleHandler>(); container.Register <InventoryHandler>(); container.Collection.Register(typeof(IHandleMessages <>), typeof(ControllerModule).Assembly); container.Collection.Append(typeof(IHandleMessages <>), typeof(IncomingOperationTaskHandler <>)); container.RegisterSingleton(() => new Id64Generator()); container.Register <IOperationTaskDispatcher, OperationTaskDispatcher>(); //use placement calculator of Host container.Register(serviceProvider.GetService <IPlacementCalculator>); container.Register(() => { var optionsBuilder = new DbContextOptionsBuilder <StateStoreContext>(); serviceProvider.GetService <IDbContextConfigurer <StateStoreContext> >().Configure(optionsBuilder); return(new StateStoreContext(optionsBuilder.Options)); }, Lifestyle.Scoped); container.ConfigureRebus(configurer => configurer .Transport(t => serviceProvider.GetService <IRebusTransportConfigurer>().Configure(t, QueueNames.Controllers)) .Routing(r => r.TypeBased() .Map(MessageTypes.ByRecipient(MessageRecipient.Controllers), QueueNames.Controllers) // agent routing is not registered here by design. Agent commands will be routed by agent name ) .Options(x => { x.SimpleRetryStrategy(); x.SetNumberOfWorkers(5); }) .Timeouts(t => serviceProvider.GetService <IRebusTimeoutConfigurer>().Configure(t)) .Sagas(s => serviceProvider.GetService <IRebusSagasConfigurer>().Configure(s)) .Subscriptions(s => serviceProvider.GetService <IRebusSubscriptionConfigurer>().Configure(s)) .Serialization(x => x.UseNewtonsoftJson(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None })) .Logging(x => x.ColoredConsole(LogLevel.Debug)).Start()); }
public void ConfigureContainer(IServiceProvider serviceProvider, Container container) { container.Collection.Register(typeof(IHandleMessages <>), typeof(ApiModule).Assembly); container.Register <IOperationManager, OperationManager>(Lifestyle.Scoped); container.ConfigureRebus(configurer => { return(configurer .Transport(t => serviceProvider.GetRequiredService <IRebusTransportConfigurer>().ConfigureAsOneWayClient(t)) .Routing(x => x.TypeBased() .Map(MessageTypes.ByRecipient(MessageRecipient.Controllers), QueueNames.Controllers)) .Options(x => { x.SimpleRetryStrategy(); x.SetNumberOfWorkers(5); }) .Serialization(x => x.UseNewtonsoftJson(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None })) .Logging(x => x.ColoredConsole()).Start()); }); }