示例#1
0
 static void StartBroker()
 {
     var setting = new BrokerSetting();
     setting.NotifyWhenMessageArrived = false;
     setting.DeleteMessageInterval = 1000;
     new BrokerController(setting).Initialize().Start();
 }
示例#2
0
        private BrokerController(BrokerSetting setting)
        {
            Setting = setting ?? new BrokerSetting();

            Setting.BrokerInfo.Valid();
            if (Setting.NameServerList == null || Setting.NameServerList.Count() == 0)
            {
                throw new ArgumentException("NameServerList is empty.");
            }

            _latestMessageIds               = new string[Setting.LatestMessageShowCount];
            _producerManager                = ObjectContainer.Resolve <ProducerManager>();
            _consumerManager                = ObjectContainer.Resolve <ConsumerManager>();
            _messageStore                   = ObjectContainer.Resolve <IMessageStore>();
            _consumeOffsetStore             = ObjectContainer.Resolve <IConsumeOffsetStore>();
            _queueStore                     = ObjectContainer.Resolve <IQueueStore>();
            _getTopicConsumeInfoListService = ObjectContainer.Resolve <GetTopicConsumeInfoListService>();
            _getConsumerListService         = ObjectContainer.Resolve <GetConsumerListService>();
            _scheduleService                = ObjectContainer.Resolve <IScheduleService>();
            _binarySerializer               = ObjectContainer.Resolve <IBinarySerializer>();
            _suspendedPullRequestManager    = ObjectContainer.Resolve <SuspendedPullRequestManager>();
            _chunkReadStatisticService      = ObjectContainer.Resolve <IChunkStatisticService>();
            _tpsStatisticService            = ObjectContainer.Resolve <ITpsStatisticService>();

            _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.BrokerInfo.ProducerAddress.ToEndPoint(), Setting.SocketSetting);
            _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.BrokerInfo.ConsumerAddress.ToEndPoint(), Setting.SocketSetting);
            _adminSocketRemotingServer    = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.BrokerInfo.AdminAddress.ToEndPoint(), Setting.SocketSetting);

            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);
            _producerSocketRemotingServer.RegisterConnectionEventListener(new ProducerConnectionEventListener(this));
            _consumerSocketRemotingServer.RegisterConnectionEventListener(new ConsumerConnectionEventListener(this));
            RegisterRequestHandlers();
            _nameServerRemotingClientList = Setting.NameServerList.ToRemotingClientList(Setting.SocketSetting).ToList();
        }
示例#3
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(
                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.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();
        }
示例#4
0
 static void StartBroker()
 {
     var setting = new BrokerSetting();
     setting.NotifyWhenMessageArrived = false;
     setting.RemoveConsumedMessageInterval = 1000;
     new BrokerController(setting).Start();
 }
示例#5
0
 static void Main(string[] args)
 {
     InitializeEQueue();
     var setting = new BrokerSetting();
     setting.NotifyWhenMessageArrived = false;
     setting.DeleteMessageInterval = 1000;
     new BrokerController(setting).Initialize().Start();
     Console.ReadLine();
 }
示例#6
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;
        }
示例#7
0
 public static BrokerController Create(BrokerSetting setting = null)
 {
     if (_instance != null)
     {
         throw new NotSupportedException("Broker controller cannot be create twice.");
     }
     _instance = new BrokerController(setting);
     return _instance;
 }
示例#8
0
 public static BrokerController Create(BrokerSetting setting = null)
 {
     if (_instance != null)
     {
         throw new NotSupportedException("Broker controller cannot be create twice.");
     }
     _instance = new BrokerController(setting);
     return(_instance);
 }
示例#9
0
 static void Main(string[] args)
 {
     InitializeEQueue();
     var setting = new BrokerSetting
     {
         TopicDefaultQueueCount = 1
     };
     BrokerController.Create(setting).Start();
     Console.ReadLine();
 }
示例#10
0
 public BrokerController(BrokerSetting setting)
 {
     Setting = setting ?? new BrokerSetting();
     SuspendedPullRequestManager = new SuspendedPullRequestManager();
     ConsumerManager = new ConsumerManager();
     _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().Name);
     _messageService = ObjectContainer.Resolve<IMessageService>();
     _producerSocketRemotingServer = new SocketRemotingServer("ProducerRemotingServer", Setting.ProducerSocketSetting, new ProducerSocketEventListener(this));
     _consumerSocketRemotingServer = new SocketRemotingServer("ConsumerRemotingServer", Setting.ConsumerSocketSetting, new ConsumerSocketEventListener(this));
     _clientManager = new ClientManager(this);
 }
示例#11
0
 public BrokerController(BrokerSetting setting)
 {
     Setting = setting ?? new BrokerSetting();
     SuspendedPullRequestManager = new SuspendedPullRequestManager();
     ConsumerManager             = new ConsumerManager();
     _logger         = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);
     _messageService = ObjectContainer.Resolve <IMessageService>();
     _producerSocketRemotingServer = new SocketRemotingServer("ProducerRemotingServer", Setting.ProducerSocketSetting, new ProducerSocketEventListener(this));
     _consumerSocketRemotingServer = new SocketRemotingServer("ConsumerRemotingServer", Setting.ConsumerSocketSetting, new ConsumerSocketEventListener(this));
     _clientManager = new ClientManager(this);
     _messageService.SetBrokerContrller(this);
 }
示例#12
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.");
 }
示例#13
0
 private BrokerController(BrokerSetting setting)
 {
     Setting = setting ?? new BrokerSetting();
     _consumerManager = ObjectContainer.Resolve<ConsumerManager>();
     _messageStore = ObjectContainer.Resolve<IMessageStore>();
     _offsetManager = ObjectContainer.Resolve<IOffsetManager>();
     _queueService = ObjectContainer.Resolve<IQueueService>();
     _messageService = ObjectContainer.Resolve<IMessageService>();
     _suspendedPullRequestManager = ObjectContainer.Resolve<SuspendedPullRequestManager>();
     _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.ProducerIPEndPoint);
     _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.ConsumerIPEndPoint, this);
     _adminSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.AdminIPEndPoint);
     _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName);
     RegisterRequestHandlers();
 }
示例#14
0
 private BrokerController(BrokerSetting setting)
 {
     Setting                       = setting ?? new BrokerSetting();
     _consumerManager              = ObjectContainer.Resolve <ConsumerManager>();
     _messageStore                 = ObjectContainer.Resolve <IMessageStore>();
     _offsetManager                = ObjectContainer.Resolve <IOffsetManager>();
     _queueService                 = ObjectContainer.Resolve <IQueueService>();
     _messageService               = ObjectContainer.Resolve <IMessageService>();
     _suspendedPullRequestManager  = ObjectContainer.Resolve <SuspendedPullRequestManager>();
     _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.ProducerIPEndPoint);
     _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.ConsumerIPEndPoint, this);
     _adminSocketRemotingServer    = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.AdminIPEndPoint);
     _logger                       = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);
     RegisterRequestHandlers();
 }
示例#15
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;
        }
示例#16
0
        private BrokerController(BrokerSetting setting)
        {
            Setting = setting ?? new BrokerSetting();
            _consumerManager = ObjectContainer.Resolve<ConsumerManager>();
            _messageStore = ObjectContainer.Resolve<IMessageStore>();
            _consumeOffsetStore = ObjectContainer.Resolve<IConsumeOffsetStore>();
            _queueStore = ObjectContainer.Resolve<IQueueStore>();
            _suspendedPullRequestManager = ObjectContainer.Resolve<SuspendedPullRequestManager>();
            _chunkReadStatisticService = ObjectContainer.Resolve<IChunkStatisticService>();

            _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.ProducerAddress, Setting.SocketSetting);
            _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.ConsumerAddress, Setting.SocketSetting);
            _adminSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.AdminAddress, Setting.SocketSetting);

            _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName);
            _consumerSocketRemotingServer.RegisterConnectionEventListener(new ConsumerConnectionEventListener(this));
            RegisterRequestHandlers();

            _service = new ConsoleEventHandlerService();
            _service.RegisterClosingEventHandler(eventCode => { Shutdown(); });
        }
示例#17
0
        private BrokerController(BrokerSetting setting)
        {
            Setting                      = setting ?? new BrokerSetting();
            _consumerManager             = ObjectContainer.Resolve <ConsumerManager>();
            _messageStore                = ObjectContainer.Resolve <IMessageStore>();
            _consumeOffsetStore          = ObjectContainer.Resolve <IConsumeOffsetStore>();
            _queueStore                  = ObjectContainer.Resolve <IQueueStore>();
            _suspendedPullRequestManager = ObjectContainer.Resolve <SuspendedPullRequestManager>();
            _chunkReadStatisticService   = ObjectContainer.Resolve <IChunkStatisticService>();

            _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.ProducerAddress, Setting.SocketSetting);
            _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.ConsumerAddress, Setting.SocketSetting);
            _adminSocketRemotingServer    = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.AdminAddress, Setting.SocketSetting);

            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);
            _consumerSocketRemotingServer.RegisterConnectionEventListener(new ConsumerConnectionEventListener(this));
            RegisterRequestHandlers();

            _service = new ConsoleEventHandlerService();
            _service.RegisterClosingEventHandler(eventCode => { Shutdown(); });
        }
示例#18
0
 public static BrokerController Create(BrokerSetting setting = null)
 {
     _instance = new BrokerController(setting);
     return(_instance);
 }
示例#19
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.");
        }
示例#20
0
 public static BrokerController Create(BrokerSetting setting = null)
 {
     _instance = new BrokerController(setting);
     return _instance;
 }