public static ENodeConfiguration StartKafka(this ENodeConfiguration enodeConfiguration) { if (_isKafkaStarted) { _commandService.InitializeENode(); _eventPublisher.InitializeENode(); _applicationMessagePublisher.InitializeENode(); _publishableExceptionPublisher.InitializeENode(); _commandConsumer.InitializeENode(); _eventConsumer.InitializeENode(); _applicationMessageConsumer.InitializeENode(); _publishableExceptionConsumer.InitializeENode(); return(enodeConfiguration); } var produceSetting = new ProducerSetting() { BrokerEndPoints = _brokerEndPoints }; _commandService.InitializeKafka(produceSetting, new CommandResultProcessor().Initialize(SocketUtils.GetLocalIPV4().ToString(), 9001));//Dns.GetHostName() _eventPublisher.InitializeKafka(produceSetting); _applicationMessagePublisher.InitializeKafka(produceSetting); _publishableExceptionPublisher.InitializeKafka(produceSetting); var consumerSetting = new ConsumerSetting() { BrokerEndPoints = _brokerEndPoints, CommitConsumerOffsetInterval = 100 }; _commandConsumer = new CommandConsumer().InitializeKafka(consumerSetting).Subscribe("CommandTopic"); _eventConsumer = new DomainEventConsumer().InitializeKafka(consumerSetting).Subscribe("EventTopic"); _applicationMessageConsumer = new ApplicationMessageConsumer().InitializeKafka(consumerSetting).Subscribe("ApplicationMessageTopic"); _publishableExceptionConsumer = new PublishableExceptionConsumer().InitializeKafka(consumerSetting).Subscribe("PublishableExceptionTopic"); _eventConsumer.Start(); _commandConsumer.Start(); _applicationMessageConsumer.Start(); _publishableExceptionConsumer.Start(); _applicationMessagePublisher.Start(); _publishableExceptionPublisher.Start(); _eventPublisher.Start(); _commandService.Start(); _isKafkaStarted = true; return(enodeConfiguration); }
public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration) { if (_isEQueueStarted) { _commandService.InitializeENode(); _eventPublisher.InitializeENode(); _applicationMessagePublisher.InitializeENode(); _publishableExceptionPublisher.InitializeENode(); _commandConsumer.InitializeENode(); _eventConsumer.InitializeENode(); _applicationMessageConsumer.InitializeENode(); _publishableExceptionConsumer.InitializeENode(); return(enodeConfiguration); } var brokerStorePath = @"d:\equeue-store-ut"; var brokerSetting = new BrokerSetting(chunkFileStoreRootPath: brokerStorePath); if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } _nameServerController = new NameServerController(); _broker = BrokerController.Create(brokerSetting); _commandService.InitializeEQueue(new CommandResultProcessor().Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9001))); _eventPublisher.InitializeEQueue(); _applicationMessagePublisher.InitializeEQueue(); _publishableExceptionPublisher.InitializeEQueue(); _commandConsumer = new CommandConsumer().InitializeEQueue(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.LastOffset }).Subscribe("CommandTopic"); _eventConsumer = new DomainEventConsumer().InitializeEQueue(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.LastOffset }).Subscribe("EventTopic"); _applicationMessageConsumer = new ApplicationMessageConsumer().InitializeEQueue(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.LastOffset }).Subscribe("ApplicationMessageTopic"); _publishableExceptionConsumer = new PublishableExceptionConsumer().InitializeEQueue(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.LastOffset }).Subscribe("PublishableExceptionTopic"); _nameServerController.Start(); _broker.Start(); _eventConsumer.Start(); _commandConsumer.Start(); _applicationMessageConsumer.Start(); _publishableExceptionConsumer.Start(); _applicationMessagePublisher.Start(); _publishableExceptionPublisher.Start(); _eventPublisher.Start(); _commandService.Start(); WaitAllProducerTopicQueuesAvailable(); WaitAllConsumerLoadBalanceComplete(); _isEQueueStarted = true; return(enodeConfiguration); }