public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); var producerSetting = new ProducerSetting { BrokerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerProducerPort), BrokerAdminAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort) }; var consumerSetting = new ConsumerSetting { BrokerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerConsumerPort), BrokerAdminAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort) }; _domainEventPublisher = new DomainEventPublisher(producerSetting); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_domainEventPublisher); _commandService = new CommandService(null, producerSetting); configuration.SetDefault<ICommandService, CommandService>(_commandService); _commandConsumer = new CommandConsumer("RegistrationCommandConsumerGroup", consumerSetting).Subscribe(Topics.RegistrationCommandTopic); _eventConsumer = new DomainEventConsumer("RegistrationEventConsumerGroup", consumerSetting).Subscribe(Topics.RegistrationDomainEventTopic); _applicationMessageConsumer = new ApplicationMessageConsumer("RegistrationMessageConsumerGroup", consumerSetting) .Subscribe(Topics.ConferenceApplicationMessageTopic) .Subscribe(Topics.PaymentApplicationMessageTopic); 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 static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration, bool useMockDomainEventPublisher = false, bool useMockApplicationMessagePublisher = false, bool useMockPublishableExceptionPublisher = false) { var configuration = enodeConfiguration.GetCommonConfiguration(); var brokerStorePath = @"c:\equeue-store"; var brokerSetting = new BrokerSetting(brokerStorePath); if (Directory.Exists(brokerStorePath)) { Directory.Delete(brokerStorePath, true); } configuration.RegisterEQueueComponents(); _broker = BrokerController.Create(brokerSetting); _commandService = new CommandService(new CommandResultProcessor(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9001))); _eventPublisher = new DomainEventPublisher(); _applicationMessagePublisher = new ApplicationMessagePublisher(); _publishableExceptionPublisher = new PublishableExceptionPublisher(); if (useMockDomainEventPublisher) { configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, MockDomainEventPublisher>(); } else { configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher); } if (useMockApplicationMessagePublisher) { configuration.SetDefault<IMessagePublisher<IApplicationMessage>, MockApplicationMessagePublisher>(); } else { configuration.SetDefault<IMessagePublisher<IApplicationMessage>, ApplicationMessagePublisher>(_applicationMessagePublisher); } if (useMockPublishableExceptionPublisher) { configuration.SetDefault<IMessagePublisher<IPublishableException>, MockPublishableExceptionPublisher>(); } else { configuration.SetDefault<IMessagePublisher<IPublishableException>, PublishableExceptionPublisher>(_publishableExceptionPublisher); } configuration.SetDefault<ICommandService, CommandService>(_commandService); _commandConsumer = new CommandConsumer(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.FirstOffset }).Subscribe("CommandTopic"); _eventConsumer = new DomainEventConsumer(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.FirstOffset }).Subscribe("EventTopic"); _applicationMessageConsumer = new ApplicationMessageConsumer(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.FirstOffset }).Subscribe("ApplicationMessageTopic"); _publishableExceptionConsumer = new PublishableExceptionConsumer(setting: new ConsumerSetting { ConsumeFromWhere = ConsumeFromWhere.FirstOffset }).Subscribe("PublishableExceptionTopic"); return enodeConfiguration; }