【问题标题】:PoolingHttpClientConnectionManager - rest connection if specific status code is returnedPoolingHttpClientConnectionManager - 如果返回特定状态码,则休息连接
【发布时间】:2021-12-21 01:19:02
【问题描述】:

我正在使用 PoolingHttpClientConnectionManager。但是,当我不希望它保持连接时,它会保持连接。因此我的问题是,如果从客户端调用返回特定的 httpStatusCode,有没有办法让 PoolingHttpClientConnectionManager 从其队列中删除连接?

逻辑上是这样的(最好)

if(HttpStatusCode != 200) {
  then drop connection from pool
} 

或类似的东西:

if (HttpStatusCode == 501) {
  then drop connection from pool
}

请注意我使用的是 Spring Boot 和 Rest 模板。

【问题讨论】:

    标签: spring-boot connection-pooling


    【解决方案1】:

    能够使用实现 ConnectionReuseStrategy 并将其设置在我的 HttpClient 上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-12
      • 2021-01-04
      • 1970-01-01
      相关资源
      最近更新 更多