-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
Currently, configuring implementation-specific properties for HTTPClient instances—such as idleTimeout or maxConnections—requires custom logic like this:
@Bean
public RestClientCustomizer restClientBuilderCustomizer() {
CloseableHttpClient pooledHttpClient = ...
... //Configure the properties here
return builder -> builder.requestFactory(new HttpComponentsClientHttpRequestFactory(pooledHttpClient));
}While I understand the reasoning for not exposing every possible setting for every HTTP client implementation, there are several common properties that could be standardized at a higher level:
- maxConnections
- maxIdleTimeBeforeEviction (when pooling)
- maxLifetime
- keepAlive
These settings are widely applicable across implementations and align closely with what developers expect from other resource pools (e.g., database connection pools).
Libraries like RestEasy have already introduced similar high-level configuration options for their consumers, which simplifies tuning and promotes consistency.
I did a quick search through existing issues and couldn’t find prior discussion on why this hasn’t been considered. I’m curious about the community’s thoughts on introducing a standardized way to configure these common properties across HTTP client implementations.
Edit:
I have created a repository to show the common configs that would be nice to add and how they are configured currently with Apache and Reactor.
https://github.com/miller79/sample-httpclient-configurations