public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); var brokerStorePath = @"d:\equeue-store"; if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } configuration.RegisterEQueueComponents(); _broker = BrokerController.Create(); _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)); _commandService = new CommandService(_commandResultProcessor); _eventPublisher = new DomainEventPublisher(); configuration.SetDefault<ICommandService, CommandService>(_commandService); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher); //注意,这里实例化之前,需要确保各种MessagePublisher要先注入到IOC,因为CommandConsumer, DomainEventConsumer都依赖于IMessagePublisher<T> _commandConsumer = new CommandConsumer(); _eventConsumer = new DomainEventConsumer(); _commandConsumer.Subscribe("NoteCommandTopic"); _eventConsumer.Subscribe("NoteEventTopic"); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); var consumerSetting = new ConsumerSetting { HeartbeatBrokerInterval = 1000, UpdateTopicQueueCountInterval = 1000, RebalanceInterval = 1000 }; var commandExecutedMessageConsumer = new Consumer(consumerSetting, "CommandExecutedMessageConsumer", "CommandExecutedMessageConsumerGroup_" + ObjectId.GenerateNewId().ToString()); var domainEventHandledMessageConsumer = new Consumer(consumerSetting, "DomainEventHandledMessageConsumer", "DomainEventHandledMessageConsumerGroup_" + ObjectId.GenerateNewId().ToString()); _commandResultProcessor = new CommandResultProcessor(commandExecutedMessageConsumer, domainEventHandledMessageConsumer); _commandService = new CommandService(_commandResultProcessor); configuration.SetDefault<ICommandService, CommandService>(_commandService); _commandResultProcessor.SetExecutedCommandMessageTopic("ExecutedCommandMessageTopic"); _commandResultProcessor.SetDomainEventHandledMessageTopic("DomainEventHandledMessageTopic"); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); var brokerStorePath = @"d:\equeue-store"; if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } configuration.RegisterEQueueComponents(); _broker = BrokerController.Create(); _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)); _commandService = new CommandService(_commandResultProcessor); _applicationMessagePublisher = new ApplicationMessagePublisher(); _domainEventPublisher = new DomainEventPublisher(); _exceptionPublisher = new PublishableExceptionPublisher(); configuration.SetDefault<ICommandService, CommandService>(_commandService); configuration.SetDefault<IMessagePublisher<IApplicationMessage>, ApplicationMessagePublisher>(_applicationMessagePublisher); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_domainEventPublisher); configuration.SetDefault<IMessagePublisher<IPublishableException>, PublishableExceptionPublisher>(_exceptionPublisher); _commandConsumer = new CommandConsumer().Subscribe("BankTransferCommandTopic"); _applicationMessageConsumer = new ApplicationMessageConsumer().Subscribe("BankTransferApplicationMessageTopic"); _eventConsumer = new DomainEventConsumer().Subscribe("BankTransferEventTopic"); _exceptionConsumer = new PublishableExceptionConsumer().Subscribe("BankTransferExceptionTopic"); return enodeConfiguration; }
public CommandService(CommandResultProcessor commandResultProcessor, ProducerSetting setting, string id) { _commandResultProcessor = commandResultProcessor; _producer = new Producer(setting, id); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _commandTopicProvider = ObjectContainer.Resolve<ICommandTopicProvider>(); _commandTypeCodeProvider = ObjectContainer.Resolve<ICommandTypeCodeProvider>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().Name); }
public CommandService(CommandResultProcessor commandResultProcessor = null, string id = null, ProducerSetting setting = null) { _commandResultProcessor = commandResultProcessor; _producer = new Producer(id ?? DefaultCommandServiceProcuderId, setting ?? new ProducerSetting()); _jsonSerializer = ObjectContainer.Resolve<IJsonSerializer>(); _commandTopicProvider = ObjectContainer.Resolve<ITopicProvider<ICommand>>(); _commandTypeCodeProvider = ObjectContainer.Resolve<ITypeCodeProvider>(); _commandRouteKeyProvider = ObjectContainer.Resolve<ICommandRoutingKeyProvider>(); _sendMessageService = new SendQueueMessageService(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _ioHelper = ObjectContainer.Resolve<IOHelper>(); }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)); _commandService = new CommandService(_commandResultProcessor); configuration.SetDefault<ICommandService, CommandService>(_commandService); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); _commandResultProcessor = new CommandResultProcessor(); _commandService = new CommandService(_commandResultProcessor); configuration.SetDefault<ICommandService, CommandService>(_commandService); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); configuration.SetDefault<ICommandTopicProvider, CommandTopicManager>(); configuration.SetDefault<IEventTopicProvider, EventTopicManager>(); configuration.SetDefault<ICommandTypeCodeProvider, CommandTypeCodeManager>(); var consumerSetting = new ConsumerSetting { HeartbeatBrokerInterval = 1000, UpdateTopicQueueCountInterval = 1000, RebalanceInterval = 1000 }; var eventConsumerSetting = new ConsumerSetting { HeartbeatBrokerInterval = 1000, UpdateTopicQueueCountInterval = 1000, RebalanceInterval = 1000, MessageHandleMode = MessageHandleMode.Sequential }; _broker = new BrokerController().Initialize(); var commandExecutedMessageConsumer = new Consumer(consumerSetting, "CommandExecutedMessageConsumer", "CommandExecutedMessageConsumerGroup_" + ObjectId.GenerateNewId().ToString()); var domainEventHandledMessageConsumer = new Consumer(consumerSetting, "DomainEventHandledMessageConsumer", "DomainEventHandledMessageConsumerGroup_" + ObjectId.GenerateNewId().ToString()); _commandResultProcessor = new CommandResultProcessor(commandExecutedMessageConsumer, domainEventHandledMessageConsumer); _commandService = new CommandService(_commandResultProcessor); _commandExecutedMessageSender = new CommandExecutedMessageSender(); _domainEventHandledMessageSender = new DomainEventHandledMessageSender(); _eventPublisher = new EventPublisher(); configuration.SetDefault<ICommandService, CommandService>(_commandService); configuration.SetDefault<IEventPublisher, EventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(consumerSetting, _commandExecutedMessageSender); _eventConsumer = new EventConsumer(eventConsumerSetting, _domainEventHandledMessageSender); _commandConsumer.Subscribe("NoteCommandTopic"); _eventConsumer.Subscribe("NoteEventTopic"); _commandResultProcessor.SetExecutedCommandMessageTopic("ExecutedCommandMessageTopic"); _commandResultProcessor.SetDomainEventHandledMessageTopic("DomainEventHandledMessageTopic"); return enodeConfiguration; }
public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration) { var nameServerEndpoint = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.NameServerPort); var nameServerEndpoints = new List <IPEndPoint> { nameServerEndpoint }; var commandResultProcessor = new CommandResultProcessor().Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.TimerTaskPort)); _commandService.Initialize(commandResultProcessor, new ProducerSetting { NameServerList = nameServerEndpoints }); _commandService.Start(); return(enodeConfiguration); }
public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration) { var nameServerEndpoint = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort); var nameServerEndpoints = new List <IPEndPoint> { nameServerEndpoint }; var commandResultProcessor = new CommandResultProcessor().Initialize(new IPEndPoint(IPAddress.Loopback, 9000)); _commandService.InitializeEQueue(commandResultProcessor, new ProducerSetting { NameServerList = nameServerEndpoints }); _commandService.Start(); return(enodeConfiguration); }
public static ENodeConfiguration StartKafka(this ENodeConfiguration enodeConfiguration) { var kafkaConfig = ObjectContainer.Resolve <Jane.ENode.IKafkaConfiguration>(); var producerSetting = new ProducerSetting { BrokerEndPoints = kafkaConfig.BrokerEndPoints }; _commandResultProcessor = new CommandResultProcessor() .Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9003)); _commandService.InitializeKafka(producerSetting, _commandResultProcessor); _commandResultProcessor.Start(); _commandService.Start(); return(enodeConfiguration); }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); string dbConfig = System.Configuration.ConfigurationManager.ConnectionStrings["IntDbConn"].ConnectionString; var messageStoreSetting = new SqlServerMessageStoreSetting { ConnectionString = dbConfig, DeleteMessageHourOfDay = -1 }; var offsetManagerSetting = new SqlServerOffsetManagerSetting { ConnectionString = dbConfig }; configuration .RegisterEQueueComponents() .UseSqlServerMessageStore(messageStoreSetting) .UseSqlServerOffsetManager(offsetManagerSetting); _broker = new BrokerController(); _commandResultProcessor = new CommandResultProcessor(); _commandService = new CommandService(_commandResultProcessor); _eventPublisher = new EventPublisher(); configuration.SetDefault<ICommandService, CommandService>(_commandService); configuration.SetDefault<IPublisher<EventStream>, EventPublisher>(_eventPublisher); configuration.SetDefault<IPublisher<DomainEventStream>, EventPublisher>(_eventPublisher); configuration.SetDefault<IPublisher<IEvent>, EventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(); _eventConsumer = new EventConsumer(); var commandTopics = ObjectContainer.Resolve<ITopicProvider<ICommand>>().GetAllTopics(); var eventTopics = ObjectContainer.Resolve<ITopicProvider<IEvent>>().GetAllTopics(); commandTopics.ForEach(topic => _commandConsumer.Subscribe(topic)); eventTopics.ForEach(topic => _eventConsumer.Subscribe(topic)); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); ConfigSettings.Initialize(); var nameServerEndpoint = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort); var nameServerEndpoints = new List <IPEndPoint> { nameServerEndpoint }; var commandResultProcessor = new CommandResultProcessor(new IPEndPoint(IPAddress.Loopback, 9000)); _commandService = new CommandService(commandResultProcessor, new ProducerSetting { NameServerList = nameServerEndpoints }); configuration.SetDefault <ICommandService, CommandService>(_commandService); return(enodeConfiguration); }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); _broker = BrokerController.Create(); _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)); _commandService = new CommandService(_commandResultProcessor); _eventPublisher = new DomainEventPublisher(); configuration.SetDefault <ICommandService, CommandService>(_commandService); configuration.SetDefault <IMessagePublisher <DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(); _eventConsumer = new DomainEventConsumer(); _commandConsumer.Subscribe("NoteCommandTopic"); _eventConsumer.Subscribe("NoteEventTopic"); return(enodeConfiguration); }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); _broker = new BrokerController(); _commandResultProcessor = new CommandResultProcessor(); _commandService = new CommandService(_commandResultProcessor); _eventPublisher = new EventPublisher(); configuration.SetDefault<ICommandService, CommandService>(_commandService); configuration.SetDefault<IEventPublisher, EventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(); _eventConsumer = new EventConsumer(); _commandConsumer.Subscribe("BankTransferCommandTopic"); _eventConsumer.Subscribe("BankTransferEventTopic"); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); var brokerStorePath = @"d:\equeue-store-test"; if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } configuration.RegisterEQueueComponents(); _broker = BrokerController.Create(new BrokerSetting(brokerStorePath)); _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)); _commandService = new CommandService(_commandResultProcessor); _eventPublisher = new DomainEventPublisher(); configuration.SetDefault<ICommandService, CommandService>(_commandService); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(); _eventConsumer = new DomainEventConsumer(); _commandConsumer .Subscribe("AccountCommandTopic") .Subscribe("SectionCommandTopic") .Subscribe("PostCommandTopic") .Subscribe("ReplyCommandTopic"); _eventConsumer .Subscribe("AccountEventTopic") .Subscribe("SectionEventTopic") .Subscribe("PostEventTopic") .Subscribe("ReplyEventTopic"); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); var brokerStorePath = @"c:\forum-equeue-store-test"; if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } configuration.RegisterEQueueComponents(); _broker = BrokerController.Create(new BrokerSetting(brokerStorePath)); _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)); _commandService = new CommandService(_commandResultProcessor); _eventPublisher = new DomainEventPublisher(); configuration.SetDefault <ICommandService, CommandService>(_commandService); configuration.SetDefault <IMessagePublisher <DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(); _eventConsumer = new DomainEventConsumer(); _commandConsumer .Subscribe("AccountCommandTopic") .Subscribe("SectionCommandTopic") .Subscribe("PostCommandTopic") .Subscribe("ReplyCommandTopic"); _eventConsumer .Subscribe("AccountEventTopic") .Subscribe("SectionEventTopic") .Subscribe("PostEventTopic") .Subscribe("ReplyEventTopic"); return(enodeConfiguration); }
public CommandService(CommandResultProcessor commandResultProcessor) : this(commandResultProcessor, new ProducerSetting()) { }
public static ENodeConfiguration StartKafka(this ENodeConfiguration enodeConfiguration) { var produceSetting = new ProducerSetting() { BrokerEndPoints = _brokerEndPoints }; var commandConsumerSetting = new ConsumerSetting { BrokerEndPoints = _brokerEndPoints, CommitConsumerOffsetInterval = 100, GroupName = "CommandConsumerGroup" }; var eventConsumerSetting = new ConsumerSetting { BrokerEndPoints = _brokerEndPoints, CommitConsumerOffsetInterval = 100, GroupName = "DomainEventConsumerGroup" }; var applicationMessageConsumerSetting = new ConsumerSetting { BrokerEndPoints = _brokerEndPoints, CommitConsumerOffsetInterval = 100, GroupName = "ApplicationMessageConsumerGroup" }; var domainExceptionConsumerSetting = new ConsumerSetting { BrokerEndPoints = _brokerEndPoints, CommitConsumerOffsetInterval = 100, GroupName = "DomainExceptionConsumerGroup" }; _commandConsumer = new CommandConsumer() .InitializeKafka(commandConsumerSetting) .Subscribe("CommandTopic"); _eventConsumer = new DomainEventConsumer() .InitializeKafka(eventConsumerSetting) .Subscribe("EventTopic"); _applicationMessageConsumer = new ApplicationMessageConsumer() .InitializeKafka(applicationMessageConsumerSetting) .Subscribe("ApplicationMessageTopic"); _domainExceptionConsumer = new DomainExceptionConsumer() .InitializeKafka(domainExceptionConsumerSetting) .Subscribe("DomainExceptionTopic"); _commandResultProcessor = new CommandResultProcessor() .Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9003)); _commandService.InitializeKafka(produceSetting, _commandResultProcessor); _eventPublisher.InitializeKafka(produceSetting); _applicationMessagePublisher.InitializeKafka(produceSetting); _domainExceptionPublisher.InitializeKafka(produceSetting); _commandConsumer.Start(); _eventConsumer.Start(); _applicationMessageConsumer.Start(); _domainExceptionConsumer.Start(); _commandService.Start(); _eventPublisher.Start(); _applicationMessagePublisher.Start(); _domainExceptionPublisher.Start(); return(enodeConfiguration); }
public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration) { if (_isEQueueStarted) { _commandService.InitializeENode(); _eventPublisher.InitializeENode(); _applicationMessagePublisher.InitializeENode(); _domainExceptionPublisher.InitializeENode(); _commandConsumer.InitializeENode(); _eventConsumer.InitializeENode(); _applicationMessageConsumer.InitializeENode(); _domainExceptionConsumer.InitializeENode(); return(enodeConfiguration); } var localIp = SocketUtils.GetLocalIPV4(); var nameserverPoint = 9493; var nameserverSetting = new NameServerSetting { BindingAddress = new IPEndPoint(localIp, nameserverPoint) }; var brokerStorePath = @"d:\equeue-store-enode-ut"; var brokerSetting = new BrokerSetting(chunkFileStoreRootPath: brokerStorePath) { NameServerList = new List <IPEndPoint> { new IPEndPoint(localIp, nameserverPoint) } }; brokerSetting.BrokerInfo.ProducerAddress = new IPEndPoint(localIp, 5000).ToAddress(); brokerSetting.BrokerInfo.ConsumerAddress = new IPEndPoint(localIp, 5001).ToAddress(); brokerSetting.BrokerInfo.AdminAddress = new IPEndPoint(localIp, 5002).ToAddress(); var producerSetting = new ProducerSetting { NameServerList = new List <IPEndPoint> { new IPEndPoint(localIp, nameserverPoint) } }; var consumerSetting = new ConsumerSetting { NameServerList = new List <IPEndPoint> { new IPEndPoint(localIp, nameserverPoint) }, ConsumeFromWhere = ConsumeFromWhere.LastOffset }; if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } _nameServerController = new NameServerController(nameserverSetting); _broker = BrokerController.Create(brokerSetting); var commandResultProcessor = new CommandResultProcessor().Initialize(new IPEndPoint(localIp, 9001)); _commandService.InitializeEQueue(commandResultProcessor, producerSetting); _eventPublisher.InitializeEQueue(producerSetting); _applicationMessagePublisher.InitializeEQueue(producerSetting); _domainExceptionPublisher.InitializeEQueue(producerSetting); _commandConsumer = new CommandConsumer().InitializeEQueue(setting: consumerSetting).Subscribe("CommandTopic"); _eventConsumer = new DomainEventConsumer().InitializeEQueue(setting: consumerSetting).Subscribe("EventTopic"); _applicationMessageConsumer = new ApplicationMessageConsumer().InitializeEQueue(setting: consumerSetting).Subscribe("ApplicationMessageTopic"); _domainExceptionConsumer = new DomainExceptionConsumer().InitializeEQueue(setting: consumerSetting).Subscribe("DomainExceptionTopic"); _nameServerSocketRemotingClient = new SocketRemotingClient("NameServerRemotingClient", new IPEndPoint(localIp, nameserverPoint)); _nameServerController.Start(); _broker.Start(); _eventConsumer.Start(); _commandConsumer.Start(); _applicationMessageConsumer.Start(); _domainExceptionConsumer.Start(); _applicationMessagePublisher.Start(); _domainExceptionPublisher.Start(); _eventPublisher.Start(); _commandService.Start(); _nameServerSocketRemotingClient.Start(); CreateTopic(Constants.CommandTopic); CreateTopic(Constants.EventTopic); CreateTopic(Constants.ApplicationMessageTopic); CreateTopic(Constants.ExceptionTopic); WaitAllProducerTopicQueuesAvailable(); WaitAllConsumerLoadBalanceComplete(); _isEQueueStarted = true; return(enodeConfiguration); }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); _broker = new BrokerController(); _commandResultProcessor = new CommandResultProcessor(); _commandService = new CommandService(_commandResultProcessor); _eventPublisher = new DomainEventPublisher(); configuration.SetDefault<ICommandService, CommandService>(_commandService); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(); _eventConsumer = new DomainEventConsumer(); _commandConsumer .Subscribe("AccountCommandTopic") .Subscribe("SectionCommandTopic") .Subscribe("PostCommandTopic") .Subscribe("ReplyCommandTopic"); _eventConsumer .Subscribe("AccountEventTopic") .Subscribe("SectionEventTopic") .Subscribe("PostEventTopic") .Subscribe("ReplyEventTopic"); return enodeConfiguration; }
public static ENodeConfiguration StartKafka(this ENodeConfiguration enodeConfiguration) { var kafkaConfig = ObjectContainer.Resolve <Jane.ENode.IKafkaConfiguration>(); var producerSetting = new ProducerSetting { BrokerEndPoints = kafkaConfig.BrokerEndPoints }; var commandConsumerSetting = new ConsumerSetting { BrokerEndPoints = kafkaConfig.BrokerEndPoints, GroupName = "BoundedContextCommandConsumerGroup" }; var eventConsumerSetting = new ConsumerSetting { BrokerEndPoints = kafkaConfig.BrokerEndPoints, GroupName = "BoundedContextDomainEventConsumerGroup" }; var applicationMessageConsumerSetting = new ConsumerSetting { BrokerEndPoints = kafkaConfig.BrokerEndPoints, GroupName = "BoundedContextApplicationMessageConsumerGroup" }; var domainExceptionConsumerSetting = new ConsumerSetting { BrokerEndPoints = kafkaConfig.BrokerEndPoints, GroupName = "BoundedContextDomainExceptionConsumerGroup" }; _commandConsumer = new CommandConsumer() .InitializeKafka(commandConsumerSetting) .Subscribe(new List <string>() { BoundedContextTopics.BoundedContextDomainCommandTopic }); _eventConsumer = new DomainEventConsumer() .InitializeKafka(eventConsumerSetting) .Subscribe(new List <string>() { BoundedContextTopics.BoundedContextDomainDomainEventTopic }); _applicationMessageConsumer = new ApplicationMessageConsumer() .InitializeKafka(applicationMessageConsumerSetting) .Subscribe(new List <string>() { BoundedContextTopics.BoundedContextDomainApplicationMessageTopic }); _domainExceptionConsumer = new DomainExceptionConsumer() .InitializeKafka(domainExceptionConsumerSetting) .Subscribe(new List <string>() { BoundedContextTopics.BoundedContextDomainExceptionTopic }); _commandResultProcessor = new CommandResultProcessor() .Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9003)); _commandService.InitializeKafka(producerSetting, _commandResultProcessor); _eventPublisher.InitializeKafka(producerSetting); _applicationMessagePublisher.InitializeKafka(producerSetting); _domainExceptionPublisher.InitializeKafka(producerSetting); _commandConsumer.Start(); _eventConsumer.Start(); _applicationMessageConsumer.Start(); _domainExceptionConsumer.Start(); _commandResultProcessor.Start(); _commandService.Start(); _eventPublisher.Start(); _applicationMessagePublisher.Start(); _domainExceptionPublisher.Start(); return(enodeConfiguration); }
public CommandService(CommandResultProcessor commandResultProcessor, string name, ProducerSetting setting) : this(commandResultProcessor, setting, string.Format("{0}@{1}@{2}", SocketUtils.GetLocalIPV4(), string.IsNullOrEmpty(name) ? typeof(CommandService).Name : name, ObjectId.GenerateNewId())) { }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); var brokerStorePath = @"c:\forum-equeue-store-test"; if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } configuration.RegisterEQueueComponents(); var nameServerEndpoint = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort); var nameServerEndpoints = new List <IPEndPoint> { nameServerEndpoint }; var nameServerSetting = new NameServerSetting() { BindingAddress = nameServerEndpoint }; _nameServer = new NameServerController(nameServerSetting); var brokerSetting = new BrokerSetting(false, brokerStorePath); brokerSetting.NameServerList = nameServerEndpoints; brokerSetting.BrokerInfo.ProducerAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.BrokerProducerPort).ToAddress(); brokerSetting.BrokerInfo.ConsumerAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.BrokerConsumerPort).ToAddress(); brokerSetting.BrokerInfo.AdminAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.BrokerAdminPort).ToAddress(); _broker = BrokerController.Create(brokerSetting); _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(IPAddress.Loopback, 9000)); _commandService = new CommandService(_commandResultProcessor, new ProducerSetting { NameServerList = nameServerEndpoints }); _eventPublisher = new DomainEventPublisher(new ProducerSetting { NameServerList = nameServerEndpoints }); configuration.SetDefault <ICommandService, CommandService>(_commandService); configuration.SetDefault <IMessagePublisher <DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher); _commandConsumer = new CommandConsumer(setting: new ConsumerSetting { NameServerList = nameServerEndpoints }); _eventConsumer = new DomainEventConsumer(setting: new ConsumerSetting { NameServerList = nameServerEndpoints }); _commandConsumer .Subscribe("AccountCommandTopic") .Subscribe("SectionCommandTopic") .Subscribe("PostCommandTopic") .Subscribe("ReplyCommandTopic"); _eventConsumer .Subscribe("AccountEventTopic") .Subscribe("SectionEventTopic") .Subscribe("PostEventTopic") .Subscribe("ReplyEventTopic"); return(enodeConfiguration); }
public CommandService(CommandResultProcessor commandResultProcessor, ProducerSetting setting) : this(commandResultProcessor, null, setting) { }