public NmsSessionPool(NmsConnection connection, AcknowledgementMode acknowledgementMode, NmsConnectionPoolSettings settings) { this.connection = connection; this.AcknowledgementMode = acknowledgementMode; this.idleSessions = new Queue<NmsPooledSession>(); this.referencedSessions = new HashSet<NmsPooledSession>(); this.settings = settings; }
public NmsConnectionPool() { this.Init(); var config = (EasyNmsSection)ConfigurationManager.GetSection("easyNms"); this.settings = new NmsConnectionPoolSettings() { ConnectionCount = config.ConnectionPool.NumberOfConnections, MaximumSessionsPerConnection = config.ConnectionPool.MaxSessionsPerConnection, MinimumSessionsPerConnection = config.ConnectionPool.MinSessionsPerConnection, AcknowledgementMode = config.ConnectionPool.AcknowledgementMode, AutoGrowSessions = config.ConnectionPool.AutoGrowSessions }; Type epManagerType = null; try { epManagerType = Type.GetType(config.ConnectionPool.EndPointManager.Type); if (epManagerType.GetInterface("INmsEndPointManager") == null) throw new ConfigurationErrorsException("The type '" + config.ConnectionPool.EndPointManager.Type + "' does not implement INmsEndPointManager."); } catch (Exception) { throw new ConfigurationErrorsException("Could not find type '" + config.ConnectionPool.EndPointManager.Type + "'."); } endpointManager = (INmsEndPointManager)Activator.CreateInstance(epManagerType); if (config.ConnectionPool.EndPointManager.Properties != null && config.ConnectionPool.EndPointManager.Properties.Count > 0) { foreach (var pInfo in epManagerType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { foreach (PropertyElement prop in config.ConnectionPool.EndPointManager.Properties) { if (prop.Name == pInfo.Name) { var conv = TypeDescriptor.GetConverter(pInfo.PropertyType); if (conv.CanConvertFrom(typeof(string))) { var value = conv.ConvertFrom(prop.Value); pInfo.SetValue(endpointManager, value, null); } } } } } foreach (EndPointElement ep in config.ConnectionPool.EndPoints) { NmsCredentials creds = null; if (ep.Credentials != null && (ep.Credentials.Username != string.Empty || ep.Credentials.Password != string.Empty)) creds = new NmsCredentials(ep.Credentials.Username, ep.Credentials.Password); var newep = new NmsEndPoint(ep.Uri, creds); endpointManager.AddEndPoint(newep); } }
public NmsConnectionPool(IConnectionFactory connectionFactory, NmsConnectionPoolSettings settings) : this() { this.Init(); this.connectionFactory = connectionFactory; this.settings = settings; this.endpointManager = new RoundRobinNmsEndPointManager(); foreach (var ep in settings.EndPoints) this.endpointManager.AddEndPoint(ep); }
public void Dispose() { lock (this) { this.isDisposed = true; this.InnerStop(); this.connectionFactory = null; this.connections = null; this.settings = null; } }
public void Dispose() { lock (this) { this.InnerStop(); this.connection = null; this.settings = null; this.idleSessions = null; this.referencedSessions = null; this.IsDisposed = true; } }
public NmsSessionPool(NmsConnection connection, NmsConnectionPoolSettings settings) : this(connection, connection.acknowledgementMode, settings) { }