private bool Connect() { if (isConnecting) return false; isConnecting = true; try { var ret = redis.ZRevRange("ZSET:PROXIES", 0, 0); if (ret.Length < 1) { return false; } string buf = System.Text.Encoding.UTF8.GetString(ret[0]); var r = buf.Split('#'); string _proxyGuid = r[0]; proxyGuid = _proxyGuid; string connectionString = r[1]; requester = new Requester(guid, connectionString, publisherPort); var sub = requester.GetSubscriberConnectionString(); if (sub == String.Empty) return false; subscriber = new Subscriber(sub, _proxyGuid, guid); isConnecting = false; foreach (var c in channels) { subscriber.Subscribe(c); } return true; } catch (System.Exception e) { log.ErrorFormat("Exception on ESBClient.Connect(): {0}", e.ToString()); isConnecting = false; return false; } }
public void Dispose() { isDisposing = true; log.InfoFormat("ESBClient {0} dispose", guid); isWork = false; foreach (var w in workerList) { w.Abort(); } publisher.Dispose(); publisher = null; subscriber.Dispose(); subscriber = null; redis.Dispose(); redis = null; isDisposing = false; }