Class PooledConnectionFactory

  • All Implemented Interfaces:
    jakarta.jms.ConnectionFactory

    public class PooledConnectionFactory
    extends Object
    implements jakarta.jms.ConnectionFactory
    A ConnectionFactory which pools Connection for reuse.
    • Field Detail

      • maxFreeConnections

        int maxFreeConnections
        The maximum number of free connections for an identity in the pool.
      • createdCnx

        int createdCnx
      • allocatedcnx

        int allocatedcnx
      • freedCnx

        int freedCnx
      • maxUsedCnx

        int maxUsedCnx
    • Constructor Detail

      • PooledConnectionFactory

        public PooledConnectionFactory​(jakarta.jms.ConnectionFactory cf)
        Creates a new pool for the specified ConnectionFactory.
        Parameters:
        cf - The ConnectionFactory used to really create the connections.
      • PooledConnectionFactory

        public PooledConnectionFactory​(jakarta.jms.ConnectionFactory cf,
                                       int maxFreeConnections)
        Creates a new pool for the specified ConnectionFactory.
        Parameters:
        cf - The ConnectionFactory used to really create the connections.
        maxFreeConnections - The maximum number of free connections for an identity in the pool.
    • Method Detail

      • getConnectionFactory

        public ConnectionFactory getConnectionFactory()
        Returns the underlying ConnectionFactory used to create the connections. This ConnectionFactory object allows to configure the created connections.
        Returns:
        the underlying ConnectionFactory.
      • getMaxFreeConnections

        public int getMaxFreeConnections()
        Returns the maximum number of free connections for an identity in the pool.
        Returns:
        The maximum number of free connections in the pool.
      • setMaxFreeConnections

        public void setMaxFreeConnections​(int maxFreeConnections)
        Sets the maximum number of free connections for an identity in the pool.
        Parameters:
        maxFreeConnections - the maximum number of free connections to set
      • createConnection

        public jakarta.jms.Connection createConnection()
                                                throws jakarta.jms.JMSException
        API method, creates a connection with the default user identity. The connection is created in stopped mode.
        Specified by:
        createConnection in interface jakarta.jms.ConnectionFactory
        Returns:
        a newly created connection.
        Throws:
        jakarta.jms.JMSSecurityException - If the default identification is incorrect.
        IllegalStateException - If the server is not listening.
        jakarta.jms.JMSException
        See Also:
        ConnectionFactory.createConnection()
      • getStatistics

        public String getStatistics()
      • createConnection

        public jakarta.jms.Connection createConnection​(String name,
                                                       String password)
                                                throws jakarta.jms.JMSException
        API method, creates a connection with the specified user identity. The connection is created in stopped mode.
        Specified by:
        createConnection in interface jakarta.jms.ConnectionFactory
        Parameters:
        name - the caller's user name.
        password - the caller's password.
        Returns:
        a newly created connection.
        Throws:
        jakarta.jms.JMSSecurityException - If the user identification is incorrect.
        IllegalStateException - If the server is not listening.
        jakarta.jms.JMSException
        See Also:
        ConnectionFactory.createConnection(String, String)
      • free

        void free​(PooledConnection cnx)
           throws jakarta.jms.JMSException
        Parameters:
        cnx -
        Throws:
        jakarta.jms.JMSException
      • createConnectionPool

        protected ConnectionPool createConnectionPool​(int maxFreeConnections)
        Parameters:
        maxFreeConnections - The maximum number of free connections for an identity in the pool.
        Returns:
        The
      • createContext

        public jakarta.jms.JMSContext createContext()
        Specified by:
        createContext in interface jakarta.jms.ConnectionFactory
      • createContext

        public jakarta.jms.JMSContext createContext​(String userName,
                                                    String password)
        Specified by:
        createContext in interface jakarta.jms.ConnectionFactory
      • createContext

        public jakarta.jms.JMSContext createContext​(String userName,
                                                    String password,
                                                    int sessionMode)
        Specified by:
        createContext in interface jakarta.jms.ConnectionFactory
      • createContext

        public jakarta.jms.JMSContext createContext​(int sessionMode)
        Specified by:
        createContext in interface jakarta.jms.ConnectionFactory