Class PooledConnection

  • All Implemented Interfaces:
    javax.jms.ExceptionListener
    Direct Known Subclasses:
    PooledXAConnection

    public class PooledConnection
    extends Object
    implements javax.jms.ExceptionListener
    Holds a real JMS connection along with the session pools associated with it.

    Instances of this class are shared amongst one or more PooledConnection object and must track the session objects that are loaned out for cleanup on close as well as ensuring that the temporary destinations of the managed Connection are purged when all references to this ConnectionPool are released.

    • Field Detail

      • connection

        protected javax.jms.Connection connection
    • Constructor Detail

      • PooledConnection

        public PooledConnection​(javax.jms.Connection connection)
    • Method Detail

      • setHasExpired

        public void setHasExpired​(boolean val)
      • makeSession

        protected javax.jms.Session makeSession​(PooledSessionKey key)
                                         throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • wrap

        protected javax.jms.Connection wrap​(javax.jms.Connection connection)
      • unWrap

        protected void unWrap​(javax.jms.Connection connection)
      • start

        public void start()
                   throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • getConnection

        public javax.jms.Connection getConnection()
      • createSession

        public javax.jms.Session createSession​(boolean transacted,
                                               int ackMode)
                                        throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • close

        public void close()
      • isClosed

        public boolean isClosed()
      • incrementReferenceCount

        public void incrementReferenceCount()
      • decrementReferenceCount

        public void decrementReferenceCount()
      • idleTimeoutCheck

        public boolean idleTimeoutCheck()
        Determines if this Connection has expired.

        A PooledConnection is considered expired when all references to it are released AND the configured idleTimeout has elapsed. Once a PooledConnection is determined to have expired its underlying Connection is closed.

        Returns:
        true if this connection has expired and can be closed.
      • getIdleTimeout

        public int getIdleTimeout()
      • setIdleTimeout

        public void setIdleTimeout​(int idleTimeout)
      • getMaxSessionsPerConnection

        public int getMaxSessionsPerConnection()
      • setMaxSessionsPerConnection

        public void setMaxSessionsPerConnection​(int maActiveSessionsPerConnection)
      • isUseAnonymousProducers

        public boolean isUseAnonymousProducers()
      • setUseAnonymousProducers

        public void setUseAnonymousProducers​(boolean value)
      • getExplicitProducerCacheSize

        public int getExplicitProducerCacheSize()
      • setExplicitProducerCacheSize

        public void setExplicitProducerCacheSize​(int cacheSize)
      • getNumSessions

        public int getNumSessions()
        Returns:
        the total number of Pooled session including idle sessions that are not currently loaned out to any client.
      • getNumIdleSessions

        public int getNumIdleSessions()
        Returns:
        the total number of Sessions that are in the Session pool but not loaned out.
      • getNumActiveSessions

        public int getNumActiveSessions()
        Returns:
        the total number of Session's that have been loaned to PooledConnection instances.
      • setBlockIfSessionPoolIsFull

        public void setBlockIfSessionPoolIsFull​(boolean block)
        Configure whether the createSession method should block when there are no more idle sessions and the pool already contains the maximum number of active sessions. If false the create method will fail and throw an exception.
        Parameters:
        block - Indicates whether blocking should be used to wait for more space to create a session.
      • isBlockIfSessionPoolIsFull

        public boolean isBlockIfSessionPoolIsFull()
      • getBlockIfSessionPoolIsFullTimeout

        public long getBlockIfSessionPoolIsFullTimeout()
        Returns the timeout to use for blocking creating new sessions
        Returns:
        true if the pooled Connection createSession method will block when the limit is hit.
        See Also:
        setBlockIfSessionPoolIsFull(boolean)
      • setBlockIfSessionPoolIsFullTimeout

        public void setBlockIfSessionPoolIsFullTimeout​(long blockIfSessionPoolIsFullTimeout)
        Controls the behavior of the internal session pool. By default the call to Connection.getSession() will block if the session pool is full. This setting will affect how long it blocks and throws an exception after the timeout. The size of the session pool is controlled by the @see #maximumActive property. Whether or not the call to create session blocks is controlled by the @see #blockIfSessionPoolIsFull property
        Parameters:
        blockIfSessionPoolIsFullTimeout - - if blockIfSessionPoolIsFullTimeout is true, then use this setting to configure how long to block before retry
      • isJMSVersionSupported

        public boolean isJMSVersionSupported​(int requiredMajor,
                                             int requiredMinor)
        Checks for JMS version support in the underlying JMS Connection this pooled connection wrapper encapsulates.
        Parameters:
        requiredMajor - The JMS Major version required for a feature to be supported.
        requiredMinor - The JMS Minor version required for a feature to be supported.
        Returns:
        true if the Connection supports the version range given.
      • getParentExceptionListener

        public javax.jms.ExceptionListener getParentExceptionListener()
      • setParentExceptionListener

        public void setParentExceptionListener​(javax.jms.ExceptionListener parentExceptionListener)
      • onException

        public void onException​(javax.jms.JMSException exception)
        Specified by:
        onException in interface javax.jms.ExceptionListener
      • checkClientJMSVersionSupport

        public void checkClientJMSVersionSupport​(int requiredMajor,
                                                 int requiredMinor)
                                          throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • checkClientJMSVersionSupport

        public void checkClientJMSVersionSupport​(int requiredMajor,
                                                 int requiredMinor,
                                                 boolean runtimeEx)
                                          throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException