public MarketDataLibrary() { _wrapper = new KCBPLibraryWrapper(); if (_wrapper.GetConnectionOption().Address == "") { //_connectionOptions = SZKingdomPool.GetAvailableSZKingdom(); _collections = SZKingdomPool.GetAvailableSZKingdom(); foreach (KeyValuePair <KCBPConnectionOptions, SZKingdomConfiguration> kv in _collections) { _connectionOptions = kv.Key; Configuration = kv.Value; } _wrapper.SetConnectionOption(_connectionOptions); _wrapper.SetCliTimeOut(Configuration.Timeout); Logging.Logger.Debug("connect to SZKingdom server:ipAddress=" + Configuration.IpAddress + "port=" + Configuration.Port + "ServerName=" + Configuration.ServerName + "UserName="******"Password=" + Configuration.Password); IsConnected = false; } }
public EntityResponse <DataTable> ExecuteCommand(SZKingdomRequest request, List <SZKingdomArgument> arguments) { try { EntityResponse <DataTable> result = Retry.Do(() => ExecuteInternal(request, arguments), TimeSpan.FromMilliseconds(10), 1, exception => { _wrapper.Disconnect(); //_connectionOptions = SZKingdomPool.GetAvailableSZKingdom(); //_wrapper.SetConnectionOption(_connectionOptions); _collections = SZKingdomPool.GetAvailableSZKingdom(); foreach (KeyValuePair <KCBPConnectionOptions, SZKingdomConfiguration> kv in _collections) { _connectionOptions = kv.Key; Configuration = kv.Value; } _wrapper.SetConnectionOption(_connectionOptions); _wrapper.SetCliTimeOut(Configuration.Timeout); Logging.Logger.Debug("failover to SZKingdom Server:ipAddress=" + Configuration.IpAddress + "port=" + Configuration.Port + "ServerName=" + Configuration.ServerName + "UserName="******"Password="******"thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId + ", ExecuteCommand innerException:" + exception.InnerException.ToString() + "ExecuteCommand stackTraceException:" + exception.StackTrace.ToString() + ", class is MarketDataLibrary"); throw new Exception("金正服务暂时不可用"); //return EntityResponse<DataTable>.Error(ErrorCode.SZKingdomLibraryError, // string.Format("KCBP error code: {0}. Message: {1}.", inner.ErrorCode, inner.Message)); } catch (Exception ex) { Logging.Logger.Error("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId + ", ExecuteCommand Exception:" + ex.StackTrace.ToString() + ", class is MarketDataLibrary"); throw; } }
public static void InitializeSZkongdom() { SZKingdomConfiguration Configuration; for (int i = 0; i < poolConfiguration.Size; i++) { Configuration = SZKingdomConfiguration.LoadConfiguration("SZKingdomConfiguration" + i); KCBPConnectionOptions _connectionOptions = new KCBPConnectionOptions(); Dictionary <KCBPConnectionOptions, SZKingdomConfiguration> collections = new Dictionary <KCBPConnectionOptions, SZKingdomConfiguration>(); _connectionOptions.Address = Configuration.IpAddress; _connectionOptions.ServerName = Configuration.ServerName; _connectionOptions.Protocol = Configuration.Protocol; _connectionOptions.Port = Configuration.Port; _connectionOptions.SendQName = Configuration.SendQName; _connectionOptions.ReceiveQName = Configuration.ReceiveQName; //SZKingdomFactory.Add(_connectionOptions); collections.Add(_connectionOptions, Configuration); SZKingdomFactory.Add(i, collections); } }
public MarketDataLibraryWrapper() { int numberOfConcurrentConnections = SZKingdomConfiguration.LoadConfiguration().NumberOfConcurrentConnections; ObjectPool <MarketDataLibrary> .Instance.Limit = numberOfConcurrentConnections; }