Esempio n. 1
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration = enodeConfiguration.GetCommonConfiguration();

            configuration.RegisterEQueueComponents();

            _eventConsumer = new DomainEventConsumer();

            _eventConsumer.Subscribe("NoteEventTopic1");
            _eventConsumer.Subscribe("NoteEventTopic2");

            return(enodeConfiguration);
        }
Esempio n. 2
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration = enodeConfiguration.GetCommonConfiguration();

            configuration.RegisterEQueueComponents();

            _eventConsumer = new DomainEventConsumer(setting: new ConsumerSetting {
                ConsumeFromWhere = ConsumeFromWhere.FirstOffset
            });

            _eventConsumer.Subscribe("NoteEventTopic1");
            _eventConsumer.Subscribe("NoteEventTopic2");

            return(enodeConfiguration);
        }
Esempio n. 3
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration = enodeConfiguration.GetCommonConfiguration();

            configuration.RegisterEQueueComponents();

            _broker = new BrokerController();
            _commandResultProcessor = new CommandResultProcessor();
            _commandService         = new CommandService(_commandResultProcessor);
            _eventPublisher         = new DomainEventPublisher();

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

            _commandConsumer = new CommandConsumer();
            _eventConsumer   = new DomainEventConsumer();

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

            return(enodeConfiguration);
        }
Esempio n. 4
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            _commandService.Initialize(setting: new ProducerSetting
            {
                NameServerList = ServiceConfigSettings.NameServerEndpoints
            });

            _eventConsumer = new DomainEventConsumer().Initialize(setting: new ConsumerSetting()
            {
                NameServerList    = ServiceConfigSettings.NameServerEndpoints,
                ConsumeFromWhere  = ConsumeFromWhere.LastOffset,
                MessageHandleMode = MessageHandleMode.Parallel,
            });

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

            _commandService.Start();
            _eventConsumer.Start();

            return(enodeConfiguration);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var nameServerEndpoint  = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort);
            var nameServerEndpoints = new List <IPEndPoint> {
                nameServerEndpoint
            };

            _commandService.Initialize(setting: new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });

            _eventConsumer = new DomainEventConsumer().Initialize(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _eventConsumer
            .Subscribe("AccountEventTopic")
            .Subscribe("SectionEventTopic")
            .Subscribe("PostEventTopic")
            .Subscribe("ReplyEventTopic");

            _commandService.Start();
            _eventConsumer.Start();

            return(enodeConfiguration);
        }
Esempio n. 7
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration = enodeConfiguration.GetCommonConfiguration();

            configuration.RegisterEQueueComponents();

            ConfigSettings.Initialize();

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

            _commandService = new CommandService(setting: new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });
            configuration.SetDefault <ICommandService, CommandService>(_commandService);

            _eventConsumer = new DomainEventConsumer(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _eventConsumer
            .Subscribe("AccountEventTopic")
            .Subscribe("SectionEventTopic")
            .Subscribe("PostEventTopic")
            .Subscribe("ReplyEventTopic");

            return(enodeConfiguration);
        }
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration = enodeConfiguration.GetCommonConfiguration();

            configuration.RegisterEQueueComponents();

            _commandService = new CommandService(id: "CommandServiceForProcessManager");
            configuration.SetDefault <ICommandService, CommandService>(_commandService);

            _eventConsumer = new DomainEventConsumer();

            _eventConsumer
            .Subscribe("GrabOrderEventTopic")
            .Subscribe("ProcessingOrderEventTopic");

            return(enodeConfiguration);
        }
Esempio n. 9
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration = enodeConfiguration.GetCommonConfiguration();

            configuration.RegisterEQueueComponents();

            _commandService = new CommandService();
            configuration.SetDefault <ICommandService, CommandService>(_commandService);

            _eventConsumer = new DomainEventConsumer();
            _eventConsumer
            .Subscribe("AccountEventTopic")
            .Subscribe("SectionEventTopic")
            .Subscribe("PostEventTopic")
            .Subscribe("ReplyEventTopic");

            return(enodeConfiguration);
        }
Esempio n. 10
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var nameServerEndpoint  = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort);
            var nameServerEndpoints = new List <IPEndPoint> {
                nameServerEndpoint
            };

            _commandService.InitializeEQueue(null, new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });

            _eventPublisher.InitializeEQueue(new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });

            _commandConsumer = new CommandConsumer().InitializeEQueue(setting: new ConsumerSetting
            {
                NameServerList   = nameServerEndpoints,
                ConsumeFromWhere = ConsumeFromWhere.FirstOffset
            });
            _commandConsumer
            .Subscribe("AccountCommandTopic")
            .Subscribe("SectionCommandTopic")
            .Subscribe("PostCommandTopic")
            .Subscribe("ReplyCommandTopic");

            _eventConsumer = new DomainEventConsumer().InitializeEQueue("CommandHostGroup", setting: new ConsumerSetting
            {
                NameServerList   = nameServerEndpoints,
                ConsumeFromWhere = ConsumeFromWhere.FirstOffset
            });
            _eventConsumer.Subscribe("ReplyEventTopic");

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

            return(enodeConfiguration);
        }
Esempio n. 11
0
        public static ENodeConfiguration StartEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var nameServerEndpoint  = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.NameServerPort);
            var nameServerEndpoints = new List <IPEndPoint> {
                nameServerEndpoint
            };

            //命令生产者
            _commandService.Initialize(setting: new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });
            //异常生产者
            _exceptionPublisher.Initialize(setting: new ProducerSetting {
                NameServerList = nameServerEndpoints
            });

            //事件消费者
            _eventConsumer.Initialize(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _eventConsumer.Subscribe(Topics.ShopDomainEventTopic);

            //异常消费者
            _exceptionConsumer.Initialize(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _exceptionConsumer.Subscribe(Topics.ShopExceptionTopic);

            _commandService.Start();
            _eventConsumer.Start();
            _exceptionPublisher.Start();
            _exceptionConsumer.Start();

            return(enodeConfiguration);
        }
Esempio n. 12
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration = enodeConfiguration.GetCommonConfiguration();

            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);

            _commandConsumer = new CommandConsumer();
            _eventConsumer   = new DomainEventConsumer();

            _commandConsumer.Subscribe("NoteCommandTopic");
            _eventConsumer.Subscribe("NoteEventTopic");

            return(enodeConfiguration);
        }
Esempio n. 13
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration   = enodeConfiguration.GetCommonConfiguration();
            var brokerStorePath = @"c:\forum-equeue-store-test";

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

            configuration.RegisterEQueueComponents();

            _broker = BrokerController.Create(new BrokerSetting(brokerStorePath));
            _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);

            _commandConsumer = new CommandConsumer();
            _eventConsumer   = new DomainEventConsumer();

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

            return(enodeConfiguration);
        }
Esempio n. 14
0
        public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration)
        {
            var configuration   = enodeConfiguration.GetCommonConfiguration();
            var brokerStorePath = @"c:\forum-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);

            _commandResultProcessor = new CommandResultProcessor(new IPEndPoint(IPAddress.Loopback, 9000));
            _commandService         = new CommandService(_commandResultProcessor, new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _eventPublisher = new DomainEventPublisher(new ProducerSetting
            {
                NameServerList = nameServerEndpoints
            });

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

            _commandConsumer = new CommandConsumer(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });
            _eventConsumer = new DomainEventConsumer(setting: new ConsumerSetting
            {
                NameServerList = nameServerEndpoints
            });

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

            return(enodeConfiguration);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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);
        }