示例#1
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            //var configuration = enodeConfiguration.GetCommonConfiguration();
            _commandService.Initialize(
                new CommandResultProcessor().Initialize(
                    new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerCommandPort)));
            _eventPublisher.Initialize();

            _commandConsumer = new CommandConsumer().Initialize().Subscribe(EQueueTopics.NoteCommandTopic);
            _eventConsumer   = new DomainEventConsumer().Initialize().Subscribe(EQueueTopics.NoteEventTopic);

            var brokerStorePath = @"d:\note-sample-equeue-store";

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            _nameServer = new NameServerController();
            _broker     = BrokerController.Create();

            _nameServer.Start();
            _broker.Start();
            _commandService.Start();
            _eventConsumer.Start();
            _commandConsumer.Start();
            _eventPublisher.Start();

            WaitAllConsumerLoadBalanceComplete();

            return(enodeConfiguration);
        }
示例#2
0
        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();

            _nameServerController = new NameServerController();
            _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);
        }
示例#3
0
        private static void InitializeEQueue()
        {
            var loggerFactory = new SerilogLoggerFactory()
                                .AddFileLogger("ECommon", "logs\\ecommon")
                                .AddFileLogger("EQueue", "logs\\equeue")
                                .AddFileLogger("ENode", "logs\\enode");

            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseSerilog(loggerFactory)
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();
            ConfigSettings.Initialize();
            var setting = new NameServerSetting()
            {
                BindingAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort)
            };

            _nameServer = new NameServerController(setting);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName).Info("NameServer initialized.");
        }
示例#4
0
        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();

            _nameServerController = new NameServerController();
            _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);
        }
示例#5
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var brokerStorePath = ConfigurationManager.AppSettings["equeue-store-path"];

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            var configuration = enodeConfiguration.GetCommonConfiguration();

            _commandService.InitializeEQueue(new CommandResultProcessor().Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)));
            _eventPublisher.InitializeEQueue();
            _commandConsumer = new CommandConsumer().InitializeEQueue().Subscribe("NoteCommandTopic");
            _eventConsumer   = new DomainEventConsumer().InitializeEQueue().Subscribe("NoteEventTopic");

            _nameServerController = new NameServerController();
            _broker = BrokerController.Create(new BrokerSetting(chunkFileStoreRootPath: brokerStorePath));

            _nameServerController.Start();
            _broker.Start();
            _eventConsumer.Start();
            _commandConsumer.Start();
            _eventPublisher.Start();
            _commandService.Start();

            WaitAllProducerTopicQueuesAvailable();
            WaitAllConsumerLoadBalanceComplete();

            return(enodeConfiguration);
        }
示例#6
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration   = enodeConfiguration.GetCommonConfiguration();
            var brokerStorePath = @"c:\person-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);

            var producerSetting = new ProducerSetting
            {
                NameServerList = new List <IPEndPoint> {
                    new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort)
                }
            };
            var consumerSetting = new ConsumerSetting
            {
                NameServerList = new List <IPEndPoint> {
                    new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort)
                }
            };

            _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(IPAddress.Loopback, 9003));
            _commandService         = new CommandService(_commandResultProcessor, producerSetting);
            _eventPublisher         = new DomainEventPublisher(producerSetting);

            configuration.SetDefault <ICommandService, CommandService>(_commandService);
            configuration.SetDefault <IMessagePublisher <DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher);

            _commandConsumer = new CommandConsumer(setting: consumerSetting)
                               .Subscribe(Topics.PersonCommandTopic);
            _eventConsumer = new DomainEventConsumer(setting: consumerSetting)
                             .Subscribe(Topics.PersonDomainEventTopic);

            return(enodeConfiguration);
        }
示例#7
0
        private static void InitializeNameServer()
        {
            _configuration.RegisterEQueueComponents();
            var setting = new NameServerSetting()
            {
                BindingAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.NameServerPort)
            };

            _nameServer = new NameServerController(setting);
            _logger.Info("NameServer initialized.");
        }
示例#8
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration.RegisterEQueueComponents();
            ConfigSettings.Initialize();
            var setting = new NameServerSetting()
            {
                BindingAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort)
            };

            _nameServer = new NameServerController(setting);
            _logger.Info("NameServer initialized.");
        }
示例#9
0
        private static void InitializeNameServer()
        {
            _configuration.RegisterEQueueComponents().BuildContainer();
            var setting = new NameServerSetting()
            {
                BindingAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.NameServerPort)
            };

            _nameServer = new NameServerController(setting);
            _logger     = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName);
            _logger.Info("NameServer initialized.");
        }
        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();
            _nameServerController = new NameServerController();
            _broker         = BrokerController.Create();
            _eventPublisher = new DomainEventPublisher();
            configuration.SetDefault <IMessagePublisher <DomainEventStreamMessage>, DomainEventPublisher>(_eventPublisher);
            return(enodeConfiguration);
        }
示例#11
0
        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();
            _nameServerController = new NameServerController();
            _broker         = BrokerController.Create();
            _commandService = new CommandService();
            configuration.SetDefault <ICommandService, CommandService>(_commandService);
            return(enodeConfiguration);
        }
示例#12
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var brokerStorePath = ConfigurationManager.AppSettings["equeue-store-path"];

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            _commandService.InitializeEQueue(new CommandResultProcessor().Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9001)));
            _applicationMessagePublisher.InitializeEQueue();
            _domainEventPublisher.InitializeEQueue();
            _exceptionPublisher.InitializeEQueue();

            _nameServerController = new NameServerController();
            _broker = BrokerController.Create(new BrokerSetting(chunkFileStoreRootPath: brokerStorePath));

            _commandConsumer            = new CommandConsumer().InitializeEQueue().Subscribe(Constants.CommandTopic);
            _applicationMessageConsumer = new ApplicationMessageConsumer().InitializeEQueue().Subscribe(Constants.ApplicationMessageTopic);
            _eventConsumer     = new DomainEventConsumer().InitializeEQueue().Subscribe(Constants.EventTopic);
            _exceptionConsumer = new DomainExceptionConsumer().InitializeEQueue().Subscribe(Constants.ExceptionTopic);
            _nameServerSocketRemotingClient = new SocketRemotingClient("NameServerRemotingClient", new IPEndPoint(SocketUtils.GetLocalIPV4(), 9493));

            _nameServerController.Start();
            _broker.Start();
            _exceptionConsumer.Start();
            _eventConsumer.Start();
            _applicationMessageConsumer.Start();
            _commandConsumer.Start();
            _applicationMessagePublisher.Start();
            _domainEventPublisher.Start();
            _exceptionPublisher.Start();
            _commandService.Start();
            _nameServerSocketRemotingClient.Start();

            //生产环境不需要以下这段代码
            CreateTopic(Constants.CommandTopic);
            CreateTopic(Constants.EventTopic);
            CreateTopic(Constants.ApplicationMessageTopic);
            CreateTopic(Constants.ExceptionTopic);
            WaitAllProducerTopicQueuesAvailable();
            WaitAllConsumerLoadBalanceComplete();

            return(enodeConfiguration);
        }
示例#13
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var brokerStorePath = @"c:\equeue-store";
            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            _eventPublisher.Initialize();

            _nameServerController = new NameServerController();
            _broker = BrokerController.Create();

            _nameServerController.Start();
            _broker.Start();
            _eventPublisher.Start();
            return enodeConfiguration;
        }
示例#14
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var brokerStorePath = @"c:\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.Initialize(new CommandResultProcessor().Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9001)));
            _eventPublisher.Initialize();
            _applicationMessagePublisher.Initialize();
            _publishableExceptionPublisher.Initialize();

            _commandConsumer = new CommandConsumer().Initialize(setting: new ConsumerSetting {
                ConsumeFromWhere = ConsumeFromWhere.FirstOffset
            }).Subscribe("CommandTopic");
            _eventConsumer = new DomainEventConsumer().Initialize(setting: new ConsumerSetting {
                ConsumeFromWhere = ConsumeFromWhere.FirstOffset
            }).Subscribe("EventTopic");
            _applicationMessageConsumer = new ApplicationMessageConsumer().Initialize(setting: new ConsumerSetting {
                ConsumeFromWhere = ConsumeFromWhere.FirstOffset
            }).Subscribe("ApplicationMessageTopic");
            _publishableExceptionConsumer = new PublishableExceptionConsumer().Initialize(setting: new ConsumerSetting {
                ConsumeFromWhere = ConsumeFromWhere.FirstOffset
            }).Subscribe("PublishableExceptionTopic");

            _nameServerController.Start();
            _broker.Start();
            _eventConsumer.Start();
            _commandConsumer.Start();
            _applicationMessageConsumer.Start();
            _publishableExceptionConsumer.Start();
            _applicationMessagePublisher.Start();
            _publishableExceptionPublisher.Start();
            _eventPublisher.Start();
            _commandService.Start();
            WaitAllConsumerLoadBalanceComplete();
            return(enodeConfiguration);
        }
示例#15
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseLog4Net()
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();
            ConfigSettings.Initialize();
            var setting = new NameServerSetting()
            {
                BindingAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.NameServerPort)
            };

            _nameServer = new NameServerController(setting);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName).Info("NameServer initialized.");
        }
示例#16
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var brokerStorePath = @"d:\publish-event-equeue-store";

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            _eventPublisher.InitializeEQueue();

            _nameServerController = new NameServerController();
            _broker = BrokerController.Create(new BrokerSetting(chunkFileStoreRootPath: brokerStorePath));

            _nameServerController.Start();
            _broker.Start();
            _eventPublisher.Start();
            WaitAllProducerTopicQueuesAvailable();
            return(enodeConfiguration);
        }
示例#17
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            _commandService.Initialize(new CommandResultProcessor().Initialize(new IPEndPoint(SocketUtils.GetLocalIPV4(), 9000)));
            _applicationMessagePublisher.Initialize();
            _domainEventPublisher.Initialize();
            _exceptionPublisher.Initialize();

            _nameServerController = new NameServerController();
            _broker = BrokerController.Create();

            _commandConsumer            = new CommandConsumer().Initialize().Subscribe("BankTransferCommandTopic");
            _applicationMessageConsumer = new ApplicationMessageConsumer().Initialize().Subscribe("BankTransferApplicationMessageTopic");
            _eventConsumer     = new DomainEventConsumer().Initialize().Subscribe("BankTransferEventTopic");
            _exceptionConsumer = new PublishableExceptionConsumer().Initialize().Subscribe("BankTransferExceptionTopic");

            var brokerStorePath = @"c:\equeue-store";

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            _nameServerController.Start();
            _broker.Start();
            _exceptionConsumer.Start();
            _eventConsumer.Start();
            _applicationMessageConsumer.Start();
            _commandConsumer.Start();
            _applicationMessagePublisher.Start();
            _domainEventPublisher.Start();
            _exceptionPublisher.Start();
            _commandService.Start();

            WaitAllConsumerLoadBalanceComplete();

            return(enodeConfiguration);
        }
示例#18
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            if (_isEQueueStarted)
            {
                _commandService.InitializeENode();
                _eventPublisher.InitializeENode();

                _commandConsumer.InitializeENode();
                _eventConsumer.InitializeENode();

                return(enodeConfiguration);
            }

            var nameServerEndpoint  = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort);
            var nameServerEndpoints = new List <IPEndPoint> {
                nameServerEndpoint
            };
            var nameServerSetting = new NameServerSetting()
            {
                BindingAddress = nameServerEndpoint
            };

            _nameServerController = new NameServerController(nameServerSetting);

            var brokerStorePath = @"d:\forum-equeue-store-test";

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            var brokerSetting = new BrokerSetting(false, brokerStorePath)
            {
                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);

            _commandService.InitializeEQueue(new CommandResultProcessor().Initialize(new IPEndPoint(IPAddress.Loopback, 9000)), new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _eventPublisher.InitializeEQueue(new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _commandConsumer = new CommandConsumer().InitializeEQueue(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _eventConsumer = new DomainEventConsumer().InitializeEQueue(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });

            _commandConsumer
            .Subscribe("AccountCommandTopic")
            .Subscribe("SectionCommandTopic")
            .Subscribe("PostCommandTopic")
            .Subscribe("ReplyCommandTopic");
            _eventConsumer
            .Subscribe("AccountEventTopic")
            .Subscribe("SectionEventTopic")
            .Subscribe("PostEventTopic")
            .Subscribe("ReplyEventTopic");

            _nameServerController.Start();
            _broker.Start();
            _eventConsumer.Start();
            _commandConsumer.Start();
            _eventPublisher.Start();
            _commandService.Start();

            WaitAllConsumerLoadBalanceComplete();

            _isEQueueStarted = true;

            return(enodeConfiguration);
        }
 public SetQueueProducerVisibleForClusterRequestHandler(NameServerController nameServerController)
 {
     _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
     _nameServerController = nameServerController;
 }
 public GetTopicAccumulateInfoListRequestHandler(NameServerController nameServerController)
 {
     _clusterManager = nameServerController.ClusterManager;
     _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
 }
示例#21
0
 public SetQueueNextConsumeOffsetForClusterRequestHandler(NameServerController nameServerController)
 {
     _binarySerializer     = ObjectContainer.Resolve <IBinarySerializer>();
     _nameServerController = nameServerController;
 }
 public DeleteQueueForClusterRequestHandler(NameServerController nameServerController)
 {
     _binarySerializer     = ObjectContainer.Resolve <IBinarySerializer>();
     _nameServerController = nameServerController;
 }
 public GetAllClustersRequestHandler(NameServerController nameServerController)
 {
     _clusterManager = nameServerController.ClusterManager;
     _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
 }
示例#24
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);
        }
示例#25
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var nameServerSetting = new NameServerSetting()
            {
                BindingAddress = ServiceConfigSettings.NameServerAddress
            };

            _nameServer = new NameServerController(nameServerSetting);

            var brokerStorePath = @"c:\Lottery\lottery-equeue-store-test";

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            var brokerSetting = new BrokerSetting(false, brokerStorePath)
            {
                NameServerList = ServiceConfigSettings.NameServerEndpoints,
            };

            brokerSetting.BrokerInfo.ProducerAddress = ServiceConfigSettings.BrokerProducerServiceAddress;
            brokerSetting.BrokerInfo.ConsumerAddress = ServiceConfigSettings.BrokerConsumerServiceAddress;
            brokerSetting.BrokerInfo.AdminAddress    = ServiceConfigSettings.BrokerAdminServiceAddress;
            _broker = BrokerController.Create(brokerSetting);

            _commandService.Initialize(new CommandResultProcessor().Initialize(new IPEndPoint(IPAddress.Loopback, 9000)), new ProducerSetting
            {
                NameServerList = ServiceConfigSettings.NameServerEndpoints,
            });
            _eventPublisher.Initialize(new ProducerSetting
            {
                NameServerList = ServiceConfigSettings.NameServerEndpoints
            });
            _commandConsumer = new CommandConsumer().Initialize(setting: new ConsumerSetting
            {
                NameServerList           = ServiceConfigSettings.NameServerEndpoints,
                ConsumeFromWhere         = ConsumeFromWhere.LastOffset,
                MessageHandleMode        = MessageHandleMode.Sequential,
                IgnoreLastConsumedOffset = true,
                AutoPull = true
            });
            _eventConsumer = new DomainEventConsumer().Initialize(setting: new ConsumerSetting
            {
                NameServerList           = ServiceConfigSettings.NameServerEndpoints,
                ConsumeFromWhere         = ConsumeFromWhere.LastOffset,
                MessageHandleMode        = MessageHandleMode.Sequential,
                IgnoreLastConsumedOffset = true,
                AutoPull = true
            });

            _commandConsumer
            .Subscribe(EQueueTopics.LotteryCommandTopic)
            .Subscribe(EQueueTopics.LotteryAccountCommandTopic)
            .Subscribe(EQueueTopics.NormCommandTopic)
            ;

            _eventConsumer
            .Subscribe(EQueueTopics.LotteryEventTopic)
            .Subscribe(EQueueTopics.LotteryAccountEventTopic)
            .Subscribe(EQueueTopics.NormEventTopic);

            _nameServer.Start();
            _broker.Start();
            _eventConsumer.Start();
            _commandConsumer.Start();
            _eventPublisher.Start();
            _commandService.Start();

            //  WaitAllConsumerLoadBalanceComplete();

            return(enodeConfiguration);
        }
 public CreateTopicForClusterRequestHandler(NameServerController nameServerController)
 {
     _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
     _nameServerController = nameServerController;
 }
 public GetProducerListRequestHandler(NameServerController nameServerController)
 {
     _clusterManager   = nameServerController.ClusterManager;
     _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>();
 }
 public SetQueueNextConsumeOffsetForClusterRequestHandler(NameServerController nameServerController)
 {
     _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
     _nameServerController = nameServerController;
 }
 public GetClusterBrokerStatusInfoListRequestHandler(NameServerController nameServerController)
 {
     _clusterManager = nameServerController.ClusterManager;
     _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
 }
示例#30
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);
        }
 public RegisterBrokerRequestHandler(NameServerController nameServerController)
 {
     _clusterManager   = nameServerController.ClusterManager;
     _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>();
 }
 public SetQueueProducerVisibleForClusterRequestHandler(NameServerController nameServerController)
 {
     _binarySerializer     = ObjectContainer.Resolve <IBinarySerializer>();
     _nameServerController = nameServerController;
 }
示例#33
0
        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(chunkFileStoreRootPath: brokerStorePath);

            if (Directory.Exists(brokerStorePath))
            {
                Directory.Delete(brokerStorePath, true);
            }

            configuration.RegisterEQueueComponents();

            _nameServerController = new NameServerController();
            _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);
        }
 public GetTopicQueueInfoRequestHandler(NameServerController nameServerController)
 {
     _clusterManager   = nameServerController.ClusterManager;
     _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>();
 }
 public DeleteConsumerGroupForClusterRequestHandler(NameServerController nameServerController)
 {
     _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
     _nameServerController = nameServerController;
 }