2016-10-20 22 views
0

Env:HttpClient 4.4。 HttpClientBuilderクラスでHttpClient共有接続マネージャ

、私はこの二つの条件を相関させることはできませんよ、次のコード、

if (!this.connManagerShared){ 

    // ...some code 

    if (this.evictExpiredConnections || this.evictIdleConnections) { 

      final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor((HttpClientConnectionManager) connManagerCopy, 
        this.maxIdleTime > 0L ? this.maxIdleTime : 10L, this.maxIdleTimeUnit != null ? this.maxIdleTimeUnit : TimeUnit.SECONDS); 
      closeablesCopy1.add(new Closeable() 
      { 
       public void close() throws IOException 
       { 
        connectionEvictor.shutdown(); 
       } 
      }); 
      connectionEvictor.start(); 
    } 
    // ...some code 
} 

を見ることができます。

共有接続マネージャを使用している場合、なぜIdleConnectionEvictorを使用しないのですか?

答えて

0

HttpClientの複数のインスタンスを作成して1つの接続プールを共有する場合は、IdleConnectionEvictorのインスタンスだけが必要な場合があります。複数のIdleConnectionEvictorが、接続プールロックのために競合して、アイドル状態の接続を排除しようとすると、1つのインスタンスで十分です。

関連する問題