public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); var brokerStorePath = @"c:\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(); var brokerStorePath = @"c:\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 = null, ProducerSetting setting = null) { _commandResultProcessor = commandResultProcessor; _producer = new Producer(setting); _jsonSerializer = ObjectContainer.Resolve<IJsonSerializer>(); _commandTopicProvider = ObjectContainer.Resolve<ITopicProvider<ICommand>>(); _typeNameProvider = ObjectContainer.Resolve<ITypeNameProvider>(); _commandRouteKeyProvider = ObjectContainer.Resolve<ICommandRoutingKeyProvider>(); _sendMessageService = new SendQueueMessageService(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _ioHelper = ObjectContainer.Resolve<IOHelper>(); }