예제 #1
0
        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]);
                }
            }
        }
예제 #2
0
 public ActiveMQPoolConnection(SimplePoolConnManager poolmanager, IConnection connection)
     : base(connection)
 {
     PoolManager          = poolmanager;
     LastTimeUsedFromPool = DateTime.Now;
 }