org.apache.activemq.pool
Class ConnectionPool

java.lang.Object
  extended by org.apache.activemq.pool.ConnectionPool
Direct Known Subclasses:
XaConnectionPool

public class ConnectionPool
extends Object

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.


Constructor Summary
ConnectionPool(ActiveMQConnection connection)
           
 
Method Summary
 void close()
           
 Session createSession(boolean transacted, int ackMode)
           
 void decrementReferenceCount()
           
 boolean expiredCheck()
          Determines if this Connection has expired.
 ActiveMQConnection getConnection()
           
 long getExpiryTimeout()
           
 int getIdleTimeout()
           
 int getMaximumActiveSessionPerConnection()
           
 int getNumActiveSessions()
           
 int getNumIdleSessions()
           
 int getNumSessions()
           
 void incrementReferenceCount()
           
 boolean isBlockIfSessionPoolIsFull()
           
 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.
 void setExpiryTimeout(long expiryTimeout)
           
 void setIdleTimeout(int idleTimeout)
           
 void setMaximumActiveSessionPerConnection(int maximumActiveSessionPerConnection)
           
 void start()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionPool

public ConnectionPool(ActiveMQConnection connection)
Method Detail

start

public void start()
           throws JMSException
Throws:
JMSException

getConnection

public ActiveMQConnection getConnection()

createSession

public Session createSession(boolean transacted,
                             int ackMode)
                      throws JMSException
Throws:
JMSException

close

public void close()

incrementReferenceCount

public void incrementReferenceCount()

decrementReferenceCount

public void decrementReferenceCount()

expiredCheck

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

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

Returns:
true if this connection has expired.

getIdleTimeout

public int getIdleTimeout()

setIdleTimeout

public void setIdleTimeout(int idleTimeout)

setExpiryTimeout

public void setExpiryTimeout(long expiryTimeout)

getExpiryTimeout

public long getExpiryTimeout()

getMaximumActiveSessionPerConnection

public int getMaximumActiveSessionPerConnection()

setMaximumActiveSessionPerConnection

public void setMaximumActiveSessionPerConnection(int maximumActiveSessionPerConnection)

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()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.