private static object _connpoollock = new object(); //连接池锁 /// <summary> /// 内部连接池获取 /// </summary> /// <param name="config"></param> /// <returns></returns> private SimplePoolConnManager GetPool(ActiveMQConnConfig config) { int hash = config.GetHashCode(); if (ConnPools.ContainsKey(hash)) { return(ConnPools[hash]); } else { lock (_connpoollock) { if (!ConnPools.ContainsKey(hash)) { var pool = new SimplePoolConnManager(new ConnectionFactory(config.ActiveMQHost), config);//创建连接池 ConnPools.Add(hash, pool); } return(ConnPools[hash]); } } }
public ActiveMQPoolConnection(SimplePoolConnManager poolmanager, IConnection connection) : base(connection) { PoolManager = poolmanager; LastTimeUsedFromPool = DateTime.Now; }