Class BlockingConnectionPool

  • All Implemented Interfaces:
    ConnectionPool
    Direct Known Subclasses:
    PooledConnectionFactory

    public class BlockingConnectionPool
    extends AbstractConnectionPool
    Implements a pool of connections that has a set minimum and maximum size. The pool will not grow beyond the maximum size and when the pool is exhausted, requests for new connections will block. The length of time the pool will block is determined by getBlockWaitTime(). By default, the pool will block for 1 minute and there is no guarantee that waiting threads will be serviced in the order in which they made their request. This implementation should be used when you need to control the exact number of connections that can be created. See AbstractConnectionPool.
    Author:
    Middleware Services
    • Constructor Detail

      • BlockingConnectionPool

        public BlockingConnectionPool()
        Creates a new blocking pool.
      • BlockingConnectionPool

        public BlockingConnectionPool​(DefaultConnectionFactory cf)
        Creates a new blocking pool.
        Parameters:
        cf - connection factory
    • Method Detail

      • getBlockWaitTime

        public java.time.Duration getBlockWaitTime()
        Returns the block wait time. Default time is 1 minute.
        Returns:
        time to wait for available connections
      • setBlockWaitTime

        public void setBlockWaitTime​(java.time.Duration time)
        Sets the block wait time. Default time is 1 minute.
        Parameters:
        time - to wait for available connections
      • retrieveAvailableConnection

        protected PooledConnectionProxy retrieveAvailableConnection()
        Attempts to retrieve a connection from the available queue.
        Returns:
        connection from the pool
        Throws:
        java.util.NoSuchElementException - if the available queue is empty