Exemplo n.º 1
0
 public ESBClient(string _registryRedisAddr, ESBOptions options)
 {
     options.redisPort     = options.redisPort > 0 ? options.redisPort : 6379;
     options.publisherPort = options.redisPort > 0 ? options.publisherPort : random.Next(7000, 8000);
     options.maxInactiveTimeInMsBeforeReconnect = options.maxInactiveTimeInMsBeforeReconnect > 0 ? options.maxInactiveTimeInMsBeforeReconnect : 15000;
     Init(_registryRedisAddr, options);
 }
Exemplo n.º 2
0
        void Init(string _registryRedisAddr, ESBOptions options)
        {
            lastESBServerActiveTime = DateTime.Now;
            isReady = false;
            guid    = genGuid();
            log.InfoFormat("new ESBClient {0}", guid);
            registryRedisAddr  = _registryRedisAddr;
            redis              = new RedisClient(registryRedisAddr, options.redisPort);
            responses          = new ConcurrentDictionary <string, ResponseStruct>();
            InvokeCallBag      = new List <BlockingCollection <Message> >();
            localMethods       = new Dictionary <string, LocalInvokeMethod>();
            subscribeCallbacks = new Dictionary <string, Dictionary <string, SubscribeCallback> >();
            channels           = new List <string>();
            publisherPort      = options.publisherPort;
            publisher          = new Publisher(GetFQDN(), publisherPort);
            isWork             = true;
            maxInactiveTimeInMsBeforeReconnect = options.maxInactiveTimeInMsBeforeReconnect;

            while (isConnecting || !Connect())
            {
                Thread.Sleep(250);
            }
            log.InfoFormat("Connected with Publisher Port : {0}", publisherPort);
            (new Thread(new ThreadStart(MainLoop))).Start();

            var cpus    = Environment.ProcessorCount;
            var workers = cpus * Paragonex.Common.Helpers.Configuration.GetAppConfigValue <int>("WorkersCoresMultiplier", 1);

            log.InfoFormat("Machine have {0} cores, using {1} workers", cpus, workers);
            workerList = new List <Thread>();
            for (var i = 0; i < workers; i++)
            {
                InvokeCallBag.Add(new BlockingCollection <Message>());
                var t = new Thread(new ParameterizedThreadStart(InvokeCallWorker));
                workerList.Add(t);
                t.Start(i);
            }
            Ping();
        }
Exemplo n.º 3
0
 public ESBClient(string _registryRedisAddr, ESBOptions options)
 {
     options.redisPort = options.redisPort > 0 ? options.redisPort : 6379;
     options.publisherPort = options.redisPort > 0 ? options.publisherPort : random.Next(7000, 8000);
     options.maxInactiveTimeInMsBeforeReconnect = options.maxInactiveTimeInMsBeforeReconnect > 0 ? options.maxInactiveTimeInMsBeforeReconnect : 15000;
     Init(_registryRedisAddr, options);
 }
Exemplo n.º 4
0
        void Init(string _registryRedisAddr, ESBOptions options)
        {
            lastESBServerActiveTime = DateTime.Now;
            isReady = false;
            guid = genGuid();
            log.InfoFormat("new ESBClient {0}", guid);
            registryRedisAddr = _registryRedisAddr;
            redis = new RedisClient(registryRedisAddr, options.redisPort);
            responses = new ConcurrentDictionary<string, ResponseStruct>();
            InvokeCallBag = new List<BlockingCollection<Message>>();
            localMethods = new Dictionary<string, LocalInvokeMethod>();
            subscribeCallbacks = new Dictionary<string, Dictionary<string, SubscribeCallback>>();
            channels = new List<string>();
            publisherPort = options.publisherPort;
            publisher = new Publisher(GetFQDN(), publisherPort);
            isWork = true;
            maxInactiveTimeInMsBeforeReconnect = options.maxInactiveTimeInMsBeforeReconnect;

            while (isConnecting || !Connect())
            {
                Thread.Sleep(250);
            }
            log.InfoFormat("Connected with Publisher Port : {0}", publisherPort);
            (new Thread(new ThreadStart(MainLoop))).Start();

            var cpus = Environment.ProcessorCount;
            var workers = cpus*Paragonex.Common.Helpers.Configuration.GetAppConfigValue<int>("WorkersCoresMultiplier", 1);
            log.InfoFormat("Machine have {0} cores, using {1} workers", cpus, workers);
            workerList = new List<Thread>();
            for (var i = 0; i < workers; i++)
            {
                InvokeCallBag.Add(new BlockingCollection<Message>());
                var t = new Thread(new ParameterizedThreadStart(InvokeCallWorker));
                workerList.Add(t);
                t.Start(i);
            }
            Ping();
        }