Class HttpConnectionPoolService


  • @Named
    @Singleton
    public class HttpConnectionPoolService
    extends Object
    Factory for HTTP clients sharing a pool of connections.

    You may create multiple pools. Each is identified by a configuration "prefix" (passed to the constructor) which is used to create names of properties which will configure the pool. The properties are:

    PREFIX.client.keepAlive
    Default keep-alive time for open connections, in milliseconds
    PREFIX.client.maxTotalConnections
    maximum open connections
    PREFIX.client.maxPerRoute
    maximum open connections per service instance
    PREFIX.client.timeToLive
    maximum lifetime of a pooled connection, in seconds
    Author:
    Mark H. Wood
    • Constructor Detail

      • HttpConnectionPoolService

        public HttpConnectionPoolService​(String configPrefix)
        Construct a pool for a given set of configuration properties.
        Parameters:
        configPrefix - Configuration property names will begin with this.
    • Method Detail

      • init

        @PostConstruct
        protected void init()
      • getClient

        public org.apache.http.impl.client.CloseableHttpClient getClient()
        Create an HTTP client which uses a pooled connection.
        Returns:
        the client.