Class ConnectionPoolingApacheConfigurator

  • All Implemented Interfaces:
    ClientConfigurator, HasApacheConnectorProperties, SetsClientBuilderProperties

    public class ConnectionPoolingApacheConfigurator
    extends ApacheConfigurator
    ApacheConfigurator configurator that applies connection-pool friendly defaults for the Jersey Apache connector.

    It requires an ApacheConnectionPoolConfig describing the desired pool size and idle timeout and configures the underlying client as follows:

    • forces connection pooling and applies the provided ApacheConnectionPoolConfig
    • installs a keep-alive strategy that honours the server timeout header and falls back to the configured idle timeout
    • works around the Apache HTTP client stream-closing race in versions prior to 4.5
    • sets NoopUserTokenHandler to avoid pinning pooled connections to a user principal

    Typical usage:

     ApacheConnectionPoolConfig poolConfig =
             ApacheConnectionPoolConfig.builder()
                     .defaultMaxConnectionsPerRoute(512)
                     .totalOpenConnections(2_048)
                     .idleConnectionTimeoutInMillis(5_000L)
                     .build();
    

    ClientConfigurator configurator = new ConnectionPoolingApacheConfigurator(poolConfig);

    • Constructor Detail