예제 #1
0
        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 brokerStorePath = @"d:\equeue-store-enode-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();
            _domainExceptionPublisher.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");
            _domainExceptionConsumer = new DomainExceptionConsumer().InitializeEQueue(setting: new ConsumerSetting {
                ConsumeFromWhere = ConsumeFromWhere.LastOffset
            }).Subscribe("DomainExceptionTopic");
            _nameServerSocketRemotingClient = new SocketRemotingClient("NameServerRemotingClient", new IPEndPoint(SocketUtils.GetLocalIPV4(), 9493));

            _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);
        }
예제 #2
0
        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);
        }