partial void OnCreating() { azureSettings = InfrastructureSettings.Read("Settings.xml"); busConfig = new ServiceBusConfig(azureSettings.ServiceBus); busConfig.Initialize(); }
partial void OnCreating() { this.azureSettings = InfrastructureSettings.Read("Settings.xml"); this.azureSettings.ServiceBus.Topics.First(t => t.IsEventBus).Subscriptions.AddRange( new[] { new SubscriptionSettings { Name = "Registration.RegistrationProcessRouter", RequiresSession = true }, new SubscriptionSettings { Name = "Registration.OrderViewModelGenerator", RequiresSession = true }, new SubscriptionSettings { Name = "Registration.PricedOrderViewModelGenerator", RequiresSession = true }, new SubscriptionSettings { Name = "Registration.SeatAssignmentsViewModelGenerator", RequiresSession = true }, }); this.azureSettings.ServiceBus.Topics.First(t => !t.IsEventBus).Subscriptions.AddRange( new[] { new SubscriptionSettings { Name = "all", RequiresSession = false } }); this.busConfig = new ServiceBusConfig(this.azureSettings.ServiceBus); busConfig.Initialize(); }
public static void RegisterComponents(UnityContainer container) { #region Infrastructures string serviceBusSetting = AppDomain.CurrentDomain.BaseDirectory + "InfrastructureSetting.xml"; MobileOAuthSettings infrastructureSetting = InfrastructureSettings.Read <MobileOAuthSettings>(serviceBusSetting); ServiceBusConfig serviceBusConfig = new ServiceBusConfig(infrastructureSetting.ServiceBus); RedisCacheSetting redisCacheConfig = infrastructureSetting.RedisCache; serviceBusConfig.Initialize(); container.RegisterInstance <ITextSerializer>(new JsonTextSerializer()); container.RegisterInstance <IMetadataProvider>(new StandardMetadataProvider()); #endregion #region Command Bus container.RegisterInstance <IMessageSender>(Topics.Commands.Path, new TopicSender(infrastructureSetting.ServiceBus, Topics.Commands.Path)); container.RegisterInstance <ICommandBus>( new CommandBus( container.Resolve <IMessageSender>(Topics.Commands.Path), container.Resolve <IMetadataProvider>(), container.Resolve <ITextSerializer>() )); #endregion #region Context container.RegisterType <OAuthDbContext>( new InjectionConstructor("MobileOAuth")); #endregion #region Cache Context container.RegisterType <RedisReadClient>(new ContainerControlledLifetimeManager(), new InjectionConstructor(redisCacheConfig)); container.RegisterType <RedisWriteClient>(new ContainerControlledLifetimeManager(), new InjectionConstructor(redisCacheConfig)); #endregion container.RegisterInstance <IUserClient>(new UserClient()); container.RegisterType <IApplicationRepository, ApplicationRepository>(); container.RegisterType <IAdminUserRepository, AdminUserRepository>(); container.RegisterType <IAppService, ApplicationService>(); container.RegisterType <IAdminUserService, AdminUserService>(); container.RegisterType <IDeviceService, RedisDeviceService>(); container.RegisterType <IRefreshTokenService, RedisRefreshTokenService>(); container.RegisterType <IUserService, UserService>(); GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container); }
public void CreateV3ReadModelSubscriptions(ServiceBusSettings serviceBusSettings) { var commandsTopic = serviceBusSettings.Topics.First(t => !t.IsEventBus); serviceBusSettings.Topics.Remove(commandsTopic); var eventsTopic = serviceBusSettings.Topics.First(); eventsTopic.MigrationSupport.Clear(); var v3Subs = eventsTopic.Subscriptions.Where(s => s.Name.EndsWith("V3")).ToArray(); eventsTopic.Subscriptions.Clear(); eventsTopic.Subscriptions.AddRange(v3Subs); var config = new ServiceBusConfig(serviceBusSettings); config.Initialize(); }
partial void OnCreateContainer(IServiceCollection services, ITextSerializer serializer, IMetadataProvider metadata, ILoggerFactory loggerFactory) { var azureSettings = InfrastructureSettings.Read("Application\\Settings.xml"); var busConfig = new ServiceBusConfig(azureSettings.ServiceBus, loggerFactory); busConfig.Initialize(); // blob var blobStorageAccount = CloudStorageAccount.Parse(azureSettings.BlobStorage.ConnectionString); services.AddSingleton <IBlobStorage>(new CloudBlobStorage(blobStorageAccount, azureSettings.BlobStorage.RootContainerName, loggerFactory.CreateLogger <CloudBlobStorage>())); var topicLogger = loggerFactory.CreateLogger <TopicSender>(); var commandBus = new CommandBus(new TopicSender(azureSettings.ServiceBus, Topics.Commands.Path, topicLogger), metadata, serializer); var eventsTopicSender = new TopicSender(azureSettings.ServiceBus, Topics.Events.Path, topicLogger); services.AddSingleton <IMessageSender>(eventsTopicSender); services.AddSingleton <IMessageSender>(/*"orders", */ new TopicSender(azureSettings.ServiceBus, Topics.EventsOrders.Path, topicLogger)); services.AddSingleton <IMessageSender>(/*"seatsavailability",*/ new TopicSender(azureSettings.ServiceBus, Topics.EventsAvailability.Path, topicLogger)); var eventBus = new EventBus(eventsTopicSender, metadata, serializer); var subscriptionLogger = loggerFactory.CreateLogger <SubscriptionReceiver>(); var sessionSubscriptionLogger = loggerFactory.CreateLogger <SessionSubscriptionReceiver>(); var sessionlessCommandProcessor = new CommandProcessor(new SubscriptionReceiver(azureSettings.ServiceBus, Topics.Commands.Path, Topics.Commands.Subscriptions.Sessionless, false, subscriptionLogger), serializer, loggerFactory.CreateLogger <CommandProcessor>()); var anchorsAvailabilityCommandProcessor = new CommandProcessor(new SessionSubscriptionReceiver(azureSettings.ServiceBus, Topics.Commands.Path, Topics.Commands.Subscriptions.Anchorsavailability, false, sessionSubscriptionLogger), serializer, loggerFactory.CreateLogger <CommandProcessor>()); var synchronousCommandBus = new SynchronousCommandBusDecorator(commandBus, loggerFactory.CreateLogger <SynchronousCommandBusDecorator>()); services.AddSingleton <ICommandBus>(synchronousCommandBus); services.AddSingleton <IEventBus>(eventBus); services.AddSingleton <IProcessor>(/*"SessionlessCommandProcessor", */ sessionlessCommandProcessor); services.AddSingleton <IProcessor>(/*"AnchorsAvailabilityCommandProcessor", */ anchorsAvailabilityCommandProcessor); RegisterRepositories(services, azureSettings, loggerFactory); var serviceProvider = services.BuildServiceProvider(); RegisterEventProcessors(services, serviceProvider, busConfig, serializer, loggerFactory); var commandHandlers = serviceProvider.GetServices <ICommandHandler>().ToList(); RegisterCommandHandlers(services, commandHandlers, sessionlessCommandProcessor, anchorsAvailabilityCommandProcessor); // handle order commands inline, as they do not have competition. // TODO: Get exactly OrderCommandHandler synchronousCommandBus.Register(commandHandlers.First(s => s.GetType() == typeof(OrderCommandHandler))); // message log var messageLogAccount = CloudStorageAccount.Parse(azureSettings.MessageLog.ConnectionString); services.AddSingleton <IProcessor>(/*"EventLogger", */ new AzureMessageLogListener( new AzureMessageLogWriter(messageLogAccount, azureSettings.MessageLog.TableName), new SubscriptionReceiver(azureSettings.ServiceBus, Topics.Events.Path, Topics.Events.Subscriptions.Log, true, subscriptionLogger))); services.AddSingleton <IProcessor>(/*"OrderEventLogger", */ new AzureMessageLogListener( new AzureMessageLogWriter(messageLogAccount, azureSettings.MessageLog.TableName), new SubscriptionReceiver(azureSettings.ServiceBus, Topics.EventsOrders.Path, Topics.EventsOrders.Subscriptions.LogOrders, true, subscriptionLogger))); services.AddSingleton <IProcessor>(/*"SeatsAvailabilityEventLogger", */ new AzureMessageLogListener( new AzureMessageLogWriter(messageLogAccount, azureSettings.MessageLog.TableName), new SubscriptionReceiver(azureSettings.ServiceBus, Topics.EventsAvailability.Path, Topics.EventsAvailability.Subscriptions.LogAvail, true, subscriptionLogger))); services.AddSingleton <IProcessor>(/*"CommandLogger", */ new AzureMessageLogListener( new AzureMessageLogWriter(messageLogAccount, azureSettings.MessageLog.TableName), new SubscriptionReceiver(azureSettings.ServiceBus, Topics.Commands.Path, Topics.Commands.Subscriptions.Log, true, subscriptionLogger))); }
public static IUnityContainer CreateContainer() { UnityContainer container = new UnityContainer(); #region Infrastructure string serviceBusSetting = AppDomain.CurrentDomain.BaseDirectory + "InfrastructureSetting.xml"; MobileOAuthSettings infrastructureSetting = InfrastructureSettings.Read <MobileOAuthSettings>(serviceBusSetting); ServiceBusConfig serviceBusConfig = new ServiceBusConfig(infrastructureSetting.ServiceBus); RedisCacheSetting redisCacheConfig = infrastructureSetting.RedisCache; serviceBusConfig.Initialize(); container.RegisterInstance <ITextSerializer>(new JsonTextSerializer()); container.RegisterInstance <IMetadataProvider>(new StandardMetadataProvider()); #endregion #region Command Bus // event bus container.RegisterInstance <IMessageSender>(Topics.Commands.Path, new TopicSender(infrastructureSetting.ServiceBus, Topics.Commands.Path)); container.RegisterInstance <ICommandBus>( new CommandBus( container.Resolve <IMessageSender>(Topics.Commands.Path), container.Resolve <IMetadataProvider>(), container.Resolve <ITextSerializer>() )); #endregion #region Event Bus container.RegisterInstance <IMessageSender>(Topics.Events.Path, new TopicSender(infrastructureSetting.ServiceBus, Topics.Events.Path)); container.RegisterInstance <IEventBus>( new EventBus( container.Resolve <IMessageSender>(Topics.Events.Path), container.Resolve <IMetadataProvider>(), container.Resolve <ITextSerializer>())); #endregion #region Cache Context container.RegisterType <RedisReadClient>(new ContainerControlledLifetimeManager(), new InjectionConstructor(redisCacheConfig)); container.RegisterType <RedisWriteClient>(new ContainerControlledLifetimeManager(), new InjectionConstructor(redisCacheConfig)); #endregion #region Context container.RegisterType <OAuthDbContext>( new InjectionConstructor("MobileOAuth")); #endregion #region Repository container.RegisterType <IUserDeviceRepository, UserDeviceRepository>(); #endregion #region CommandHandler container.RegisterType <ICommandHandler, OAuthViewGenerator>("OAuthViewGenerator"); var oAuthViewGenerator = new CommandProcessor(new SessionSubscriptionReceiver(infrastructureSetting.ServiceBus, Topics.Commands.Path, Topics.Commands.Subscriptions.OAuthViewGenerator, false, new SessionSubscriptionReceiverInstrumentation(Topics.Commands.Subscriptions.OAuthViewGenerator, false)), container.Resolve <ITextSerializer>()); oAuthViewGenerator.Register(container.Resolve <ICommandHandler>("OAuthViewGenerator")); container.RegisterInstance <IProcessor>("OAuthViewGeneratorProcessor", oAuthViewGenerator); #endregion container.RegisterEventProcessor <AuthenInfoGenerator>(serviceBusConfig, Topics.Events.Subscriptions.AuthenInfoSync, false); return(container); }