public Producer(ProducerSetting setting = null, string name = null) { Name = name; Setting = setting ?? new ProducerSetting(); if (Setting.NameServerList == null || Setting.NameServerList.Count() == 0) { throw new Exception("Name server address is not specified."); } _queueSelector = ObjectContainer.Resolve<IQueueSelector>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); var clientSetting = new ClientSetting { ClientName = Name, ClusterName = Setting.ClusterName, NameServerList = Setting.NameServerList, SocketSetting = Setting.SocketSetting, OnlyFindMasterBroker = true, SendHeartbeatInterval = Setting.HeartbeatBrokerInterval, RefreshBrokerAndTopicRouteInfoInterval = Setting.RefreshBrokerAndTopicRouteInfoInterval }; _clientService = new ClientService(clientSetting, this, null); }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); var producerSetting = new ProducerSetting { BrokerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerProducerPort), BrokerAdminAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort) }; var consumerSetting = new ConsumerSetting { BrokerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerConsumerPort), BrokerAdminAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerAdminPort) }; _domainEventPublisher = new DomainEventPublisher(producerSetting); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_domainEventPublisher); _commandService = new CommandService(null, producerSetting); configuration.SetDefault<ICommandService, CommandService>(_commandService); _commandConsumer = new CommandConsumer("RegistrationCommandConsumerGroup", consumerSetting).Subscribe(Topics.RegistrationCommandTopic); _eventConsumer = new DomainEventConsumer("RegistrationEventConsumerGroup", consumerSetting).Subscribe(Topics.RegistrationDomainEventTopic); _applicationMessageConsumer = new ApplicationMessageConsumer("RegistrationMessageConsumerGroup", consumerSetting) .Subscribe(Topics.ConferenceApplicationMessageTopic) .Subscribe(Topics.PaymentApplicationMessageTopic); return enodeConfiguration; }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); var producerSetting = new ProducerSetting { BrokerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), PortConfiguration.BrokerProducerPort), BrokerAdminAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), PortConfiguration.BrokerAdminPort) }; var consumerSetting = new ConsumerSetting { BrokerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), PortConfiguration.BrokerConsumerPort), BrokerAdminAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), PortConfiguration.BrokerAdminPort) }; _applicationMessagePublisher = new ApplicationMessagePublisher(producerSetting); _domainEventPublisher = new DomainEventPublisher(producerSetting); _exceptionPublisher = new PublishableExceptionPublisher(producerSetting); configuration.SetDefault<IMessagePublisher<IApplicationMessage>, ApplicationMessagePublisher>(_applicationMessagePublisher); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_domainEventPublisher); configuration.SetDefault<IMessagePublisher<IPublishableException>, PublishableExceptionPublisher>(_exceptionPublisher); _commandConsumer = new CommandConsumer(setting: consumerSetting).Subscribe(TopicConfiguration.AccountCommandTopic); _eventConsumer = new DomainEventConsumer(setting: consumerSetting).Subscribe(TopicConfiguration.AccountDomainEventTopic); _exceptionConsumer = new PublishableExceptionConsumer(setting: consumerSetting).Subscribe(TopicConfiguration.AccountExceptionTopic); return enodeConfiguration; }
static void SendMessageTest() { _mode = ConfigurationManager.AppSettings["Mode"]; var address = ConfigurationManager.AppSettings["BrokerAddress"]; var brokerAddress = string.IsNullOrEmpty(address) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(address); var clientCount = int.Parse(ConfigurationManager.AppSettings["ClientCount"]); var messageSize = int.Parse(ConfigurationManager.AppSettings["MessageSize"]); var messageCount = int.Parse(ConfigurationManager.AppSettings["MessageCount"]); var actions = new List<Action>(); var payload = new byte[messageSize]; var topic = ConfigurationManager.AppSettings["Topic"]; var message = new Message(topic, 100, payload); for (var i = 0; i < clientCount; i++) { var setting = new ProducerSetting { BrokerAddress = new IPEndPoint(brokerAddress, 5000), BrokerAdminAddress = new IPEndPoint(brokerAddress, 5002) }; var producer = new Producer(setting).Start(); actions.Add(() => SendMessages(producer, _mode, messageCount, message)); } Task.Factory.StartNew(() => Parallel.Invoke(actions.ToArray())); }
public EventPublisher(string id, string topic, EQueueClientsProducers.ProducerSetting producerSetting) { Topic = topic; Id = id; _Logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); MessageQueue = new BlockingCollection <EQueueProtocols.Message>(); Producer = new EQueueClientsProducers.Producer(Id, producerSetting); }
public EventPublisher(ProducerSetting setting, string id) { _producer = new Producer(setting, id); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _eventTopicProvider = ObjectContainer.Resolve<IEventTopicProvider>(); _eventTypeCodeProvider = ObjectContainer.Resolve<IEventTypeCodeProvider>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().Name); }
public CommandService(CommandResultProcessor commandResultProcessor, ProducerSetting setting, string id) { _commandResultProcessor = commandResultProcessor; _producer = new Producer(setting, id); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _commandTopicProvider = ObjectContainer.Resolve<ICommandTopicProvider>(); _commandTypeCodeProvider = ObjectContainer.Resolve<ICommandTypeCodeProvider>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().Name); }
public Producer(ProducerSetting setting, string id) { Id = id; Setting = setting ?? new ProducerSetting(); _topicQueueCountDict = new ConcurrentDictionary<string, int>(); _taskIds = new List<int>(); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.BrokerPort); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _queueSelector = ObjectContainer.Resolve<IQueueSelector>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().Name); }
public CommandService(CommandResultProcessor commandResultProcessor = null, string id = null, ProducerSetting setting = null) { _commandResultProcessor = commandResultProcessor; _producer = new Producer(id ?? DefaultCommandServiceProcuderId, setting ?? new ProducerSetting()); _jsonSerializer = ObjectContainer.Resolve<IJsonSerializer>(); _commandTopicProvider = ObjectContainer.Resolve<ITopicProvider<ICommand>>(); _commandTypeCodeProvider = ObjectContainer.Resolve<ITypeCodeProvider>(); _commandRouteKeyProvider = ObjectContainer.Resolve<ICommandRoutingKeyProvider>(); _sendMessageService = new SendQueueMessageService(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _ioHelper = ObjectContainer.Resolve<IOHelper>(); }
public Producer(ProducerSetting setting) { Setting = setting ?? new ProducerSetting(); _topicQueueIdsDict = new ConcurrentDictionary<string, IList<int>>(); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.SocketSetting, Setting.LocalAddress); _adminRemotingClient = new SocketRemotingClient(Setting.BrokerAdminAddress, Setting.SocketSetting, Setting.LocalAdminAddress); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _queueSelector = ObjectContainer.Resolve<IQueueSelector>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _remotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); }
public CommandConsumer(string name, EQueueClientsConsumers.ConsumerSetting consumerSetting, string groupName, string subscribeTopic, string brokerAddress, int producerBrokerPort, IHandlerProvider handlerProvider) : base(name, consumerSetting, groupName, subscribeTopic) { HandlerProvider = handlerProvider; var producerSetting = new EQueueClientsProducers.ProducerSetting(); producerSetting.BrokerAddress = brokerAddress; producerSetting.BrokerPort = producerBrokerPort; Producer = new EQueueClientsProducers.Producer(string.Format("{0}-Reply-Producer", name), producerSetting); CommandConsumers.Add(this); }
public Producer(string id, ProducerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } Id = id; Setting = setting ?? new ProducerSetting(); _lockObject = new object(); _taskIds = new List<int>(); _topicQueueIdsDict = new ConcurrentDictionary<string, IList<int>>(); _remotingClient = new SocketRemotingClient(Setting.BrokerProducerIPEndPoint, null, this); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _queueSelector = ObjectContainer.Resolve<IQueueSelector>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); }
public Producer(string id, ProducerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } Id = id; Setting = setting ?? new ProducerSetting(); _lockObject = new object(); _taskIds = new List <int>(); _topicQueueIdsDict = new ConcurrentDictionary <string, IList <int> >(); _remotingClient = new SocketRemotingClient(Setting.BrokerProducerIPEndPoint, null, this); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _queueSelector = ObjectContainer.Resolve <IQueueSelector>(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); }
public Producer(string id, ProducerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } Id = id; Setting = setting ?? new ProducerSetting(); _lockObject = new object(); _topicQueueIdsDict = new ConcurrentDictionary<string, IList<int>>(); _remotingClient = new SocketRemotingClient(Id + ".RemotingClient", Setting.BrokerAddress, Setting.LocalAddress); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _queueSelector = ObjectContainer.Resolve<IQueueSelector>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _remotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); }
public Producer(string id, ProducerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } Id = id; Setting = setting ?? new ProducerSetting(); _lockObject = new object(); _topicQueueIdsDict = new ConcurrentDictionary <string, IList <int> >(); _remotingClient = new SocketRemotingClient(Id + ".RemotingClient", Setting.BrokerAddress, Setting.LocalAddress); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _queueSelector = ObjectContainer.Resolve <IQueueSelector>(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _remotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); }
public CommandBus(string name, ICommandHandlerProvider handlerProvider, ILinearCommandManager linearCommandManager, string brokerAddress, int producerBrokerPort, EQueueClientsConsumers.ConsumerSetting consumerSetting, string groupName, string replyTopic, string commandTopic, bool inProc) : base(name, consumerSetting, groupName, replyTopic) { CommandStateQueue = Hashtable.Synchronized(new Hashtable()); ToBeSentCommandQueue = new BlockingCollection <MessageContext>(); HandlerProvider = handlerProvider; LinearCommandManager = linearCommandManager; CommandTopic = commandTopic; ReplyTopic = replyTopic; InProc = inProc; ProducerSetting = new EQueueClientsProducers.ProducerSetting(); ProducerSetting.BrokerAddress = brokerAddress; ProducerSetting.BrokerPort = producerBrokerPort; ProducerName = name; }
public DomainEventHandledMessageSender(ProducerSetting setting) : this(null, setting) { }
public static ENodeConfiguration UseEQueue(this ENodeConfiguration enodeConfiguration) { var configuration = enodeConfiguration.GetCommonConfiguration(); configuration.RegisterEQueueComponents(); var producerSetting = new ProducerSetting { BrokerProducerIPEndPoint = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerProducerPort) }; var consumerSetting = new ConsumerSetting { BrokerConsumerIPEndPoint = new IPEndPoint(SocketUtils.GetLocalIPV4(), ConfigSettings.BrokerConsumerPort) }; _applicationMessagePublisher = new ApplicationMessagePublisher("ConferenceApplicationMessagePublisher", producerSetting); _domainEventPublisher = new DomainEventPublisher("ConferenceDomainEventPublisher", producerSetting); _exceptionPublisher = new PublishableExceptionPublisher("ConferencePublishableExceptionPublisher", producerSetting); configuration.SetDefault<IMessagePublisher<IApplicationMessage>, ApplicationMessagePublisher>(_applicationMessagePublisher); configuration.SetDefault<IMessagePublisher<DomainEventStreamMessage>, DomainEventPublisher>(_domainEventPublisher); configuration.SetDefault<IMessagePublisher<IPublishableException>, PublishableExceptionPublisher>(_exceptionPublisher); _commandConsumer = new CommandConsumer( "ConferenceCommandConsumer", "ConferenceCommandConsumerGroup", consumerSetting) .Subscribe(Topics.ConferenceCommandTopic); _eventConsumer = new DomainEventConsumer( "ConferenceEventConsumer", "ConferenceEventConsumerGroup", consumerSetting) .Subscribe(Topics.ConferenceDomainEventTopic); _exceptionConsumer = new PublishableExceptionConsumer( "ConferenceExceptionConsumer", "ConferenceExceptionConsumerGroup", consumerSetting) .Subscribe(Topics.ConferenceExceptionTopic); return enodeConfiguration; }
static void SendMessages() { var setting = new ProducerSetting { BrokerAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), 5000), BrokerAdminAddress = new IPEndPoint(SocketUtils.GetLocalIPV4(), 5002) }; var producer = new Producer(setting).Start(); var index = 0L; while (true) { var payload = Encoding.UTF8.GetBytes(index.ToString()); var message = new Message("topic1", 100, payload); SendMessageAsync(producer, message, index.ToString()); index++; Thread.Sleep(10); } }
public CommandExecutedMessageSender(ProducerSetting setting, string id) { _producer = new Producer(setting, id); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); }
public Producer(ProducerSetting setting) : this(null, setting) { }
public CommandExecutedMessageSender(ProducerSetting setting) : this(null, setting) { }
public CommandExecutedMessageSender(string name, ProducerSetting setting) : this(setting, string.Format("{0}@{1}@{2}", SocketUtils.GetLocalIPV4(), string.IsNullOrEmpty(name) ? typeof(CommandExecutedMessageSender).Name : name, ObjectId.GenerateNewId())) { }
public EventPublisher(ProducerSetting setting) : this(null, setting) { }
public CommandService(CommandResultProcessor commandResultProcessor, string name, ProducerSetting setting) : this(commandResultProcessor, setting, string.Format("{0}@{1}@{2}", SocketUtils.GetLocalIPV4(), string.IsNullOrEmpty(name) ? typeof(CommandService).Name : name, ObjectId.GenerateNewId())) { }
public CommandService(CommandResultProcessor commandResultProcessor, ProducerSetting setting) : this(commandResultProcessor, null, setting) { }
public EventPublisher(string name, ProducerSetting setting) : this(setting, string.Format("{0}@{1}@{2}", SocketUtils.GetLocalIPV4(), string.IsNullOrEmpty(name) ? typeof(EventPublisher).Name : name, ObjectId.GenerateNewId())) { }
public DomainEventHandledMessageSender(ProducerSetting setting, string id) { _producer = new Producer(setting, id); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); }