static void StartBroker() { var setting = new BrokerSetting(); setting.NotifyWhenMessageArrived = false; setting.DeleteMessageInterval = 1000; new BrokerController(setting).Initialize().Start(); }
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(); }
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(); }
static void StartBroker() { var setting = new BrokerSetting(); setting.NotifyWhenMessageArrived = false; setting.RemoveConsumedMessageInterval = 1000; new BrokerController(setting).Start(); }
static void Main(string[] args) { InitializeEQueue(); var setting = new BrokerSetting(); setting.NotifyWhenMessageArrived = false; setting.DeleteMessageInterval = 1000; new BrokerController(setting).Initialize().Start(); Console.ReadLine(); }
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; }
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; }
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); }
static void Main(string[] args) { InitializeEQueue(); var setting = new BrokerSetting { TopicDefaultQueueCount = 1 }; BrokerController.Create(setting).Start(); Console.ReadLine(); }
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); }
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); }
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."); }
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(); }
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(); }
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; }
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(); }); }
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(); }); }
public static BrokerController Create(BrokerSetting setting = null) { _instance = new BrokerController(setting); return(_instance); }
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."); }
public static BrokerController Create(BrokerSetting setting = null) { _instance = new BrokerController(setting); return _instance; }