public static IApplicationBuilder InitalizeBus(this IApplicationBuilder app, IConfiguration configuration, IApplicationLifetime lifetime) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (lifetime == null) { throw new ArgumentNullException(nameof(lifetime)); } var busControl = BusFactory.CreateBus(configuration, busConfigurator => { busConfigurator.ReceiveEndpoint("Soloco.RealTimeWeb", endpointConfiguration => { endpointConfiguration.Consumer(() => new VehicleMonitoConsumer()); }); }); if (busControl != null) { var busHandle = busControl.Start(); //todo: handler the bus lifetime by the container lifetime.ApplicationStopping.Register(() => { busHandle.Dispose(); }); } return(app); }
public static ILifetimeScope CreateLifetimeScope() { var builder = new ContainerBuilder(); //what it does behind is that it uses RabbitHutch.CreateBus() and takes the rabbit_mq connection string; IBus bus = BusFactory.CreateBus(); //here inside startup module are registered other services/components with extension methods like RegisterDatabaseContext and RegisterAutoMapper //also here the SettingsActionsBO are registered //and the settings facade as InstancePerLifetimeScope ////builder.RegisterModule(new StartUpModule()); //In some cases, you may want to pre-generate an instance of an object and add it to the container for use by registered components builder.RegisterInstance(bus).As <IBus>(); //register the setting ms itself, it is in different project ////builder.RegisterType<SettingsMicroservice>().As<IMicroservice>(); var container = builder.Build(); return(container); }
private void AddVehicles() { for (int i = 1; i <= 3; i++) { string[] vehicleArgs = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); Vehicle vehicle = null; if (i == 1) { vehicle = CarFactory.CreateCar(vehicleArgs); } else if (i == 2) { vehicle = TruckFactory.CreateTruck(vehicleArgs); } else { vehicle = BusFactory.CreateBus(vehicleArgs); } vehicles.Add(vehicle); } }
public RabbitMqRegistry() { var rabbitBuses = RabbitMqHostsConfiguration.Instance; For <IBus>().Singleton().Use(BusFactory.CreateBus(rabbitBuses.DefaultHost)); For <IBootstrapSubcribers>().Singleton().Use <BootstrapSubcribers>(); For <IMessageBus>().Singleton().Use <RabbitMessageBus>(); }
public static ILifetimeScope CreateLifetimeScope() { var builder = new ContainerBuilder(); var bus = BusFactory.CreateBus(); builder.RegisterModule(new StartUpModule()); builder.RegisterInstance(bus).As <IBus>(); builder.RegisterType <OrderMicroservice>().As <IMicroservice>(); return(builder.Build()); }
public GASender() { InitializeComponent(); _logger = LogManager.GetLogger(GetType().Name); try { var busConfiguration = ConfigService.Instance.Bus; if (busConfiguration == null) { throw new Exception("BusConfiguration must be set in config"); } var kernel = new StandardKernel(); kernel.Bind <IMessageBodySerializer>().To <DefaultJsonSerializer>().InSingletonScope(); kernel.Bind <IBusLogger>().To <CustomNLogger>().InSingletonScope(); NinjectContainerAdapter.CreateInstance(kernel); BusFactory.SetContainerFactory(NinjectContainerAdapter.GetInstance); _messageBus = BusFactory.CreateBus(); _repository = new Repository.Repository(ConfigService.Instance.Payments.W1ConnectionString); _sendService = new PaymentsService( _repository, ConfigService.Instance.Common.GoogleAnaliticsUrl, ConfigService.Instance.Common.TrackingId, ConfigService.Instance.Payments.Interval, ConfigService.Instance.Common.GoogleAnaliticsTimeout, ConfigService.Instance.Payments.StartTime, ConfigService.Instance); } catch (Exception exception) { _logger.Error(exception); throw; } }