Ejemplo n.º 1
0
        public ClientService(ClientSetting setting, Producer producer, Consumer consumer)
        {
            Ensure.NotNull(setting, "setting");
            if (producer == null && consumer == null)
            {
                throw new ArgumentException("producer or consumer must set at least one of them.");
            }
            else if (producer != null && consumer != null)
            {
                throw new ArgumentException("producer or consumer cannot set both of them.");
            }

            Interlocked.Increment(ref _instanceNumber);

            _producer = producer;
            _consumer = consumer;
            _setting = setting;
            _clientId = BuildClientId(setting.ClientName);
            _brokerConnectionDict = new ConcurrentDictionary<string, BrokerConnection>();
            _topicMessageQueueDict = new ConcurrentDictionary<string, IList<MessageQueue>>();
            _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
            _jsonSerializer = ObjectContainer.Resolve<IJsonSerializer>();
            _scheduleService = ObjectContainer.Resolve<IScheduleService>();
            _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName);
            _nameServerRemotingClientList = RemotingClientUtils.CreateRemotingClientList(_setting.NameServerList, _setting.SocketSetting).ToList();
        }