I have upgraded to spring boot 3 . I am trying to instantiate metric binder with pool connection manager.
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setDefaultMaxPerRoute(config.getMaxConnectionPerRoute());
connectionManager.setMaxTotal(config.getMaxConnectionPerRoute() * config.getNoOfRoutes());
CloseableHttpClient httpClient = HttpClientBuilder
.create().setConnectionManager(connectionManager)
.build();
new PoolingHttpClientConnectionManagerMetricsBinder(connectionManager, "my-pool").bindTo(registry);
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
restTemplate = new RestTemplate(requestFactory);
The previously used package
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
The upgraded package
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
This updated package is incompatible with PoolingHttpClientConnectionManagerMetricsBinder with issue: 'PoolingHttpClientConnectionManagerMetricsBinder(org.apache.http.pool.ConnPoolControl<org.apache.http.conn.routing.HttpRoute>, java.lang.String, java.lang.String...)' in 'io.micrometer.core.instrument.binder.httpcomponents.PoolingHttpClientConnectionManagerMetricsBinder' cannot be applied to '(org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager, java.lang.String)'
I tried to update to the old package
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
and resolve this, but this cause issue with HttpComponentsClientHttpRequestFactory
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
as the packages are incompatible 'HttpComponentsClientHttpRequestFactory(org.apache.hc.client5.http.classic.HttpClient)' in 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory' cannot be applied to '(org.apache.http.client.HttpClient)'
Need solution to resolve this or any alternative approach.
Both Spring Framework 6 and Spring Boot 3 removed support for HttpComponents 4.x (see this Spring Framework issue and this Spring Boot issue ).
If you'd like to keep the connection pool metrics in your application, I would suggest to ask the Micrometer team if they would consider supporting the new version of httpcomponents. Given the latest changes in Micrometer, the HTTP client itself could ship its own, optional, Observability instrumentation like most Spring projects do now.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.