Esempio n. 1
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseLog4Net()
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();
            ConfigSettings.Initialize();
            var storePath           = ConfigurationManager.AppSettings["equeueStorePath"];
            var nameServerEndpoint  = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort);
            var nameServerEndpoints = new List <IPEndPoint> {
                nameServerEndpoint
            };
            var brokerSetting = new BrokerSetting(false, storePath)
            {
                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);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName).Info("Broker initialized.");
        }
Esempio n. 2
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseLog4Net()
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();

            ServiceConfigSettings.Initialize();

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

            brokerSetting.BrokerInfo.ProducerAddress = ServiceConfigSettings.BrokerProducerServiceAddress;
            brokerSetting.BrokerInfo.ConsumerAddress = ServiceConfigSettings.BrokerConsumerServiceAddress;
            brokerSetting.BrokerInfo.AdminAddress    = ServiceConfigSettings.BrokerAdminServiceAddress;
            brokerSetting.BrokerInfo.BrokerName      = ServiceConfigSettings.BrokerName;
            brokerSetting.BrokerInfo.GroupName       = ServiceConfigSettings.BrokerGroup;

            _broker = BrokerController.Create(brokerSetting);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).FullName).Info("Broker initialized.");
        }
Esempio n. 3
0
        private static void InitializeEQueue()
        {
            ConfigSettings.Initialize();

            var queueStoreSetting = new SqlServerQueueStoreSetting
            {
                ConnectionString = ConfigSettings.ConferenceEQueueConnectionString
            };
            var messageStoreSetting = new SqlServerMessageStoreSetting
            {
                ConnectionString   = ConfigSettings.ConferenceEQueueConnectionString,
                MessageLogFilePath = "/home/admin/logs/conference/equeue"
            };
            var offsetManagerSetting = new SqlServerOffsetManagerSetting
            {
                ConnectionString = ConfigSettings.ConferenceEQueueConnectionString
            };

            _configuration
            .RegisterEQueueComponents()
            .UseSqlServerQueueStore(queueStoreSetting)
            .UseSqlServerMessageStore(messageStoreSetting)
            .UseSqlServerOffsetManager(offsetManagerSetting);

            var setting = new BrokerSetting
            {
                ProducerIPEndPoint = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerProducerPort),
                ConsumerIPEndPoint = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerConsumerPort),
                AdminIPEndPoint    = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort)
            };

            _broker = BrokerController.Create(setting);
            _logger.Info("EQueue initialized.");
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            using (var bootstrapper = new AbpBootstrapper())
            {
                bootstrapper.Initialize();

                var setting = new BrokerSetting(
                    bool.Parse(ConfigurationManager.AppSettings["isMemoryMode"]),
                    ConfigurationManager.AppSettings["fileStoreRootPath"],
                    chunkCacheMaxPercent: 95,
                    chunkFlushInterval: int.Parse(ConfigurationManager.AppSettings["flushInterval"]),
                    messageChunkDataSize: int.Parse(ConfigurationManager.AppSettings["chunkSize"]) * 1024 * 1024,
                    chunkWriteBuffer: int.Parse(ConfigurationManager.AppSettings["chunkWriteBuffer"]) * 1024,
                    enableCache: bool.Parse(ConfigurationManager.AppSettings["enableCache"]),
                    chunkCacheMinPercent: int.Parse(ConfigurationManager.AppSettings["chunkCacheMinPercent"]),
                    syncFlush: bool.Parse(ConfigurationManager.AppSettings["syncFlush"]),
                    messageChunkLocalCacheSize: 30 * 10000,
                    queueChunkLocalCacheSize: 10000)
                {
                    NotifyWhenMessageArrived   = bool.Parse(ConfigurationManager.AppSettings["notifyWhenMessageArrived"]),
                    MessageWriteQueueThreshold = int.Parse(ConfigurationManager.AppSettings["messageWriteQueueThreshold"])
                };
                BrokerController.Create(setting).Start();
                Console.ReadLine();
            }
        }
Esempio n. 5
0
        public static Configuration StartEqueueBroker(this Configuration configuration, int producerPort = 5000, int consumerPort = 5001, int adminPort = 5002)
        {
            var setting = new BrokerSetting(
                bool.Parse(ConfigurationManager.AppSettings["isMemoryMode"]),
                ConfigurationManager.AppSettings["fileStoreRootPath"],
                chunkCacheMaxPercent: 95,
                chunkFlushInterval: int.Parse(ConfigurationManager.AppSettings["flushInterval"]),
                messageChunkDataSize: int.Parse(ConfigurationManager.AppSettings["chunkSize"]) * 1024 * 1024,
                chunkWriteBuffer: int.Parse(ConfigurationManager.AppSettings["chunkWriteBuffer"]) * 1024,
                enableCache: bool.Parse(ConfigurationManager.AppSettings["enableCache"]),
                chunkCacheMinPercent: int.Parse(ConfigurationManager.AppSettings["chunkCacheMinPercent"]),
                messageChunkLocalCacheSize: 30 * 10000,
                queueChunkLocalCacheSize: 10000)
            {
                AutoCreateTopic            = true,
                ProducerAddress            = new IPEndPoint(SocketUtils.GetLocalIPV4(), producerPort),
                ConsumerAddress            = new IPEndPoint(SocketUtils.GetLocalIPV4(), consumerPort),
                AdminAddress               = new IPEndPoint(SocketUtils.GetLocalIPV4(), adminPort),
                NotifyWhenMessageArrived   = true,
                MessageWriteQueueThreshold = int.Parse(ConfigurationManager.AppSettings["messageWriteQueueThreshold"])
            };

            BrokerController.Create(setting).Start();
            return(configuration);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            InitializeEQueue();

            var address           = ConfigurationManager.AppSettings["nameServerAddress"];
            var nameServerAddress = string.IsNullOrEmpty(address) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(address);
            var setting           = new BrokerSetting(
                isMessageStoreMemoryMode: bool.Parse(ConfigurationManager.AppSettings["isMemoryMode"]),
                chunkFileStoreRootPath: ConfigurationManager.AppSettings["fileStoreRootPath"],
                chunkFlushInterval: int.Parse(ConfigurationManager.AppSettings["flushInterval"]),
                chunkCacheMaxCount: int.Parse(ConfigurationManager.AppSettings["chunkCacheMaxCount"]),
                chunkCacheMinCount: int.Parse(ConfigurationManager.AppSettings["chunkCacheMinCount"]),
                messageChunkDataSize: int.Parse(ConfigurationManager.AppSettings["chunkSize"]) * 1024 * 1024,
                chunkWriteBuffer: int.Parse(ConfigurationManager.AppSettings["chunkWriteBuffer"]) * 1024,
                enableCache: bool.Parse(ConfigurationManager.AppSettings["enableCache"]),
                syncFlush: bool.Parse(ConfigurationManager.AppSettings["syncFlush"]),
                messageChunkLocalCacheSize: 30 * 10000,
                queueChunkLocalCacheSize: 10000)
            {
                NotifyWhenMessageArrived      = bool.Parse(ConfigurationManager.AppSettings["notifyWhenMessageArrived"]),
                MessageWriteQueueThreshold    = int.Parse(ConfigurationManager.AppSettings["messageWriteQueueThreshold"]),
                DeleteMessageIgnoreUnConsumed = bool.Parse(ConfigurationManager.AppSettings["deleteMessageIgnoreUnConsumed"])
            };

            setting.NameServerList = new List <IPEndPoint> {
                new IPEndPoint(nameServerAddress, 9493)
            };
            setting.BrokerInfo.BrokerName      = ConfigurationManager.AppSettings["brokerName"];
            setting.BrokerInfo.GroupName       = ConfigurationManager.AppSettings["groupName"];
            setting.BrokerInfo.ProducerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), int.Parse(ConfigurationManager.AppSettings["producerPort"])).ToAddress();
            setting.BrokerInfo.ConsumerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), int.Parse(ConfigurationManager.AppSettings["consumerPort"])).ToAddress();
            setting.BrokerInfo.AdminAddress    = new IPEndPoint(SocketUtils.GetLocalIPV4(), int.Parse(ConfigurationManager.AppSettings["adminPort"])).ToAddress();
            BrokerController.Create(setting).Start();
            Console.ReadLine();
        }
Esempio n. 7
0
        static void StartBroker()
        {
            var setting = new BrokerSetting();

            setting.NotifyWhenMessageArrived = false;
            setting.DeleteMessageInterval    = 1000;
            new BrokerController(setting).Initialize().Start();
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            InitializeEQueue();
            var setting = new BrokerSetting();

            setting.NotifyWhenMessageArrived = false;
            setting.DeleteMessageInterval    = 1000;
            new BrokerController(setting).Initialize().Start();
            Console.ReadLine();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            InitializeEQueue();
            var setting = new BrokerSetting
            {
                TopicDefaultQueueCount = 1
            };

            BrokerController.Create(setting).Start();
            Console.ReadLine();
        }
Esempio n. 11
0
        private static void InitializeEQueue()
        {
            _configuration.RegisterEQueueComponents();
            var storePath = ConfigurationManager.AppSettings["equeueStorePath"];
            var setting   = new BrokerSetting(storePath)
            {
                ProducerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerProducerPort),
                ConsumerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerConsumerPort),
                AdminAddress    = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort)
            };

            _broker = BrokerController.Create(setting);
            _logger.Info("EQueue initialized.");
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            InitializeEQueue();

            var bindingIP      = ConfigurationManager.AppSettings["BindingAddress"];
            var brokerEndPoint = string.IsNullOrEmpty(bindingIP) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(bindingIP);
            var setting        = new BrokerSetting {
                ProducerIPEndPoint = new IPEndPoint(brokerEndPoint, 5000),
                ConsumerIPEndPoint = new IPEndPoint(brokerEndPoint, 5001),
                AdminIPEndPoint    = new IPEndPoint(brokerEndPoint, 5002)
            };

            BrokerController.Create(setting).Start();
            Console.ReadLine();
        }
Esempio n. 13
0
        private void InitializeEQueue()
        {
            _configuration.RegisterEQueueComponents();
            var storePath = ConfigurationManager.AppSettings["equeueStorePath"];
            var setting   = new BrokerSetting(false, storePath);

            setting.NameServerList = new List <IPEndPoint> {
                new IPEndPoint(SocketUtils.GetLocalIPV4(), 10000)
            };
            setting.BrokerInfo.BrokerName      = "GloodBroker";
            setting.BrokerInfo.GroupName       = "GloodGroupName";
            setting.BrokerInfo.ProducerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), 10001).ToAddress();
            setting.BrokerInfo.AdminAddress    = new IPEndPoint(SocketUtils.GetLocalIPV4(), 10003).ToAddress();
            _broker = BrokerController.Create(setting);
            _logger.Info("EQueue initialized.");
        }
Esempio n. 14
0
        private static void InitializeEQueue()
        {
            _configuration.RegisterEQueueComponents().BuildContainer();
            var storePath = ConfigurationManager.AppSettings["equeueStorePath"];
            var setting   = new BrokerSetting(false, storePath);

            setting.NameServerList = new List <IPEndPoint> {
                new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.NameServerPort)
            };
            setting.BrokerInfo.BrokerName      = "ConferenceBroker";
            setting.BrokerInfo.GroupName       = "ConferenceGroupName";
            setting.BrokerInfo.ProducerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerProducerPort).ToAddress();
            setting.BrokerInfo.ConsumerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerConsumerPort).ToAddress();
            setting.BrokerInfo.AdminAddress    = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort).ToAddress();
            _broker = BrokerController.Create(setting);
            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName);
            _logger.Info("Broker initialized.");
        }
Esempio n. 15
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration.RegisterEQueueComponents();
            ConfigSettings.Initialize();
            var storePath           = ConfigurationManager.AppSettings["equeueStorePath"];
            var nameServerEndpoint  = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort);
            var nameServerEndpoints = new List <IPEndPoint> {
                nameServerEndpoint
            };
            var brokerSetting = new BrokerSetting(false, storePath);

            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);
            _logger.Info("EQueue initialized.");
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        /// <summary>
        /// 初始化队列
        /// </summary>
        private static void InitializeEQueue()
        {
            _configuration.RegisterEQueueComponents();
            //EQueue配置
            var storePath = ConfigurationManager.AppSettings["equeueStorePath"];
            var setting   = new BrokerSetting(false, storePath);

            setting.NameServerList = new List <IPEndPoint> {
                new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.NameServerPort)
            };
            setting.BrokerInfo.BrokerName      = "ShopBroker";
            setting.BrokerInfo.GroupName       = "ShopGroupName";
            setting.BrokerInfo.ProducerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerProducerPort).ToAddress();
            setting.BrokerInfo.ConsumerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerConsumerPort).ToAddress();
            setting.BrokerInfo.AdminAddress    = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort).ToAddress();
            //创建broker
            _broker = BrokerController.Create(setting);
            _logger.Info("EQueue,初始化成功");
        }
Esempio n. 18
0
        public static Configuration StartEqueueBroker(this Configuration configuration,
                                                      string clusterName         = "DefaultCluster",
                                                      string nameServerAddresses = null,
                                                      int producerPort           = 5000,
                                                      int consumerPort           = 5001,
                                                      int adminPort = 5002)
        {
            var nameServerIPEndPoints = GetIPEndPoints(nameServerAddresses).ToList();

            if (nameServerIPEndPoints.Count == 0)
            {
                throw new Exception("no avaliable equeue name server address");
            }

            var setting = new BrokerSetting(
                bool.Parse(ConfigurationManager.AppSettings["isMemoryMode"]),
                ConfigurationManager.AppSettings["fileStoreRootPath"],
                chunkCacheMaxPercent: 95,
                chunkFlushInterval: int.Parse(ConfigurationManager.AppSettings["flushInterval"]),
                messageChunkDataSize: int.Parse(ConfigurationManager.AppSettings["chunkSize"]) * 1024 * 1024,
                chunkWriteBuffer: int.Parse(ConfigurationManager.AppSettings["chunkWriteBuffer"]) * 1024,
                enableCache: bool.Parse(ConfigurationManager.AppSettings["enableCache"]),
                chunkCacheMinPercent: int.Parse(ConfigurationManager.AppSettings["chunkCacheMinPercent"]),
                syncFlush: bool.Parse(ConfigurationManager.AppSettings["syncFlush"]),
                messageChunkLocalCacheSize: 30 * 10000,
                queueChunkLocalCacheSize: 10000)
            {
                NotifyWhenMessageArrived   = bool.Parse(ConfigurationManager.AppSettings["notifyWhenMessageArrived"]),
                MessageWriteQueueThreshold = int.Parse(ConfigurationManager.AppSettings["messageWriteQueueThreshold"])
            };

            setting.BrokerInfo.ClusterName     = clusterName;
            setting.NameServerList             = nameServerIPEndPoints;
            setting.BrokerInfo.BrokerName      = ConfigurationManager.AppSettings["brokerName"];
            setting.BrokerInfo.GroupName       = ConfigurationManager.AppSettings["groupName"];
            setting.BrokerInfo.ProducerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), producerPort).ToString();
            setting.BrokerInfo.ConsumerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), consumerPort).ToString();
            setting.BrokerInfo.AdminAddress    = new IPEndPoint(SocketUtils.GetLocalIPV4(), adminPort).ToString();
            BrokerController.Create(setting).Start();
            return(configuration);
        }
Esempio n. 19
0
        public static Configuration InitliaizeEQueue(this Configuration configuration,
                                                     int brokePort = 5000, int consumerPort = 5001, int producerPort = 5000)
        {
            ECommon.Configurations.Configuration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .UseJsonNet()
            .RegisterEQueueComponents();

            var setting = new BrokerSetting();

            setting.NotifyWhenMessageArrived      = false;
            setting.RemoveConsumedMessageInterval = 1000;
            setting.ProducerSocketSetting.Port    = producerPort;
            setting.ConsumerSocketSetting.Port    = consumerPort;
            setting.AdminSocketSetting.Backlog    = setting.ProducerSocketSetting.Backlog = setting.ConsumerSocketSetting.Backlog = brokePort;
            new BrokerController(setting).Start();

            return(configuration);
        }
Esempio n. 20
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);
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            InitializeEQueue();


            #region Environments Configs
            var _brokerAddress                 = Environment.GetEnvironmentVariable("BROKERSERVER_BINDINGADDRESS");
            var _nameServerAddress             = Environment.GetEnvironmentVariable("BROKERSERVER_NAMESERVERADDRESS");
            var _nameServerPort                = Environment.GetEnvironmentVariable("BROKERSERVER_NAMESERVERPORT");
            var _isMemoryMode                  = Environment.GetEnvironmentVariable("BROKERSERVER_ISMEMORYMODE");
            var _fileStoreRootPath             = Environment.GetEnvironmentVariable("BROKERSERVER_FILESTOREROOTPATH");
            var _flushInterval                 = Environment.GetEnvironmentVariable("BROKERSERVER_FLUSHINTERVAL");
            var _chunkCacheMaxCount            = Environment.GetEnvironmentVariable("BROKERSERVER_CHUNKCACHEMAXCOUNT");
            var _chunkCacheMinCount            = Environment.GetEnvironmentVariable("BROKERSERVER_CHUNKCACHEMINCOUNT");
            var _chunkSize                     = Environment.GetEnvironmentVariable("BROKERSERVER_CHUNKSIZE");
            var _chunkWriteBuffer              = Environment.GetEnvironmentVariable("BROKERSERVER_CHUNKWRITEBUFFER");
            var _enableCache                   = Environment.GetEnvironmentVariable("BROKERSERVER_ENABLECACHE");
            var _syncFlush                     = Environment.GetEnvironmentVariable("BROKERSERVER_SYNCFLUSH");
            var _notifyWhenMessageArrived      = Environment.GetEnvironmentVariable("BROKERSERVER_NOTIFYWHENMESSAGEARRIVED");
            var _messageWriteQueueThreshold    = Environment.GetEnvironmentVariable("BROKERSERVER_MESSAGEWRITEQUEUETHRESHOLD");
            var _deleteMessageIgnoreUnConsumed = Environment.GetEnvironmentVariable("BROKERSERVER_DELETEMESSAGEIGNOREUNCONSUMED");
            var _brokerName                    = Environment.GetEnvironmentVariable("BROKERSERVER_BROKERNAME");
            var _groupName                     = Environment.GetEnvironmentVariable("BROKERSERVER_GROUPNAME");
            var _producerPort                  = Environment.GetEnvironmentVariable("BROKERSERVER_PRODUCERPORT");
            var _consumerPort                  = Environment.GetEnvironmentVariable("BROKERSERVER_CONSUMERPORT");
            var _adminPort                     = Environment.GetEnvironmentVariable("BROKERSERVER_ADMINPORT");
            #endregion

            var brokerAddress                 = string.IsNullOrEmpty(_brokerAddress) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(_brokerAddress);
            var nameServerAddress             = string.IsNullOrEmpty(_nameServerAddress) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(_nameServerAddress);
            var nameServerPort                = !string.IsNullOrEmpty(_nameServerPort) && int.TryParse(_nameServerPort, out int nsPort) ? nsPort : 9493;
            var isMemoryMode                  = !string.IsNullOrEmpty(_isMemoryMode) && bool.TryParse(_isMemoryMode, out bool outIsMemoryMode) ? outIsMemoryMode : false;
            var fileStoreRootPath             = !string.IsNullOrEmpty(_fileStoreRootPath) ? _fileStoreRootPath : "/var/lib/equeue/store";
            var flushInterval                 = !string.IsNullOrEmpty(_flushInterval) && int.TryParse(_flushInterval, out int outFlushInterval) ? outFlushInterval : 100; // Milliseconds
            var chunkCacheMaxCount            = !string.IsNullOrEmpty(_chunkCacheMaxCount) && int.TryParse(_chunkCacheMaxCount, out int outChunkCacheMaxCount) ? outChunkCacheMaxCount : 2;
            var chunkCacheMinCount            = !string.IsNullOrEmpty(_chunkCacheMinCount) && int.TryParse(_chunkCacheMinCount, out int outChunkCacheMinCount) ? outChunkCacheMinCount : 1;
            var chunkSize                     = !string.IsNullOrEmpty(_chunkSize) && int.TryParse(_chunkSize, out int outChunkSize) ? outChunkSize : 256;                             // MB
            var chunkWriteBuffer              = !string.IsNullOrEmpty(_chunkWriteBuffer) && int.TryParse(_chunkWriteBuffer, out int outChunkWriteBuffer) ? outChunkWriteBuffer : 256; //KB
            var enableCache                   = !string.IsNullOrEmpty(_enableCache) && bool.TryParse(_enableCache, out bool outEnableCache) ? outEnableCache : true;
            var syncFlush                     = !string.IsNullOrEmpty(_syncFlush) && bool.TryParse(_syncFlush, out bool outSyncFlush) ? outSyncFlush : false;
            var notifyWhenMessageArrived      = !string.IsNullOrEmpty(_notifyWhenMessageArrived) && bool.TryParse(_notifyWhenMessageArrived, out bool outNotifyWhenMessageArrived) ? outNotifyWhenMessageArrived : true;
            var messageWriteQueueThreshold    = !string.IsNullOrEmpty(_messageWriteQueueThreshold) && int.TryParse(_messageWriteQueueThreshold, out int outMessageWriteQueueThreshold) ? outMessageWriteQueueThreshold : 10000;
            var deleteMessageIgnoreUnConsumed = !string.IsNullOrEmpty(_deleteMessageIgnoreUnConsumed) && bool.TryParse(_deleteMessageIgnoreUnConsumed, out bool outDeleteMessageIgnoreUnConsumed) ? outDeleteMessageIgnoreUnConsumed : false;
            var brokerName                    = !string.IsNullOrEmpty(_brokerName) ? _brokerName : "Broker1";
            var groupName                     = !string.IsNullOrEmpty(_groupName) ? _groupName : "BrokerGroup1";
            var producerPort                  = !string.IsNullOrEmpty(_producerPort) && int.TryParse(_producerPort, out int outProducerPort) ? outProducerPort : 5000;
            var consumerPort                  = !string.IsNullOrEmpty(_consumerPort) && int.TryParse(_consumerPort, out int outConsumerPort) ? outConsumerPort : 5001;
            var adminPort                     = !string.IsNullOrEmpty(_adminPort) && int.TryParse(_adminPort, out int outAdminPort) ? outAdminPort : 5002;

            var setting = new BrokerSetting(
                isMessageStoreMemoryMode: isMemoryMode,
                chunkFileStoreRootPath: fileStoreRootPath,
                chunkFlushInterval: flushInterval,
                chunkCacheMaxCount: chunkCacheMaxCount,
                chunkCacheMinCount: chunkCacheMinCount,
                messageChunkDataSize: chunkSize * 1024 * 1024,
                chunkWriteBuffer: chunkWriteBuffer * 1024,
                enableCache: enableCache,
                syncFlush: syncFlush,
                messageChunkLocalCacheSize: 30 * 10000,
                queueChunkLocalCacheSize: 10000)
            {
                NotifyWhenMessageArrived      = notifyWhenMessageArrived,
                MessageWriteQueueThreshold    = messageWriteQueueThreshold,
                DeleteMessageIgnoreUnConsumed = deleteMessageIgnoreUnConsumed
            };
            setting.NameServerList = new List <IPEndPoint> {
                new IPEndPoint(nameServerAddress, nameServerPort)
            };
            setting.BrokerInfo.BrokerName      = brokerName;
            setting.BrokerInfo.GroupName       = groupName;
            setting.BrokerInfo.ProducerAddress = new IPEndPoint(brokerAddress, producerPort).ToAddress();
            setting.BrokerInfo.ConsumerAddress = new IPEndPoint(brokerAddress, consumerPort).ToAddress();
            setting.BrokerInfo.AdminAddress    = new IPEndPoint(brokerAddress, adminPort).ToAddress();
            BrokerController.Create(setting).Start();
            Console.ReadLine();
        }
Esempio n. 22
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);
        }
Esempio n. 23
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(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);
        }
Esempio n. 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);
        }
Esempio n. 25
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);
        }