public class PooledConnectionFactory extends Object implements javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory
setTimeBetweenExpirationCheckMillis(long)
method. By
default the value is -1 which means no eviction thread will be run. Set to a non-negative value to
configure the idle eviction thread to run.Modifier and Type | Field and Description |
---|---|
protected Object |
connectionFactory |
protected AtomicBoolean |
stopped |
Constructor and Description |
---|
PooledConnectionFactory() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all connections from the pool.
|
javax.jms.Connection |
createConnection() |
protected javax.jms.Connection |
createConnection(ConnectionKey key) |
javax.jms.Connection |
createConnection(String userName,
String password) |
protected ConnectionPool |
createConnectionPool(javax.jms.Connection connection)
Delegate that creates each instance of an ConnectionPool object.
|
javax.jms.QueueConnection |
createQueueConnection() |
javax.jms.QueueConnection |
createQueueConnection(String userName,
String password) |
javax.jms.TopicConnection |
createTopicConnection() |
javax.jms.TopicConnection |
createTopicConnection(String userName,
String password) |
long |
getBlockIfSessionPoolIsFullTimeout()
Returns the timeout to use for blocking creating new sessions
|
Object |
getConnectionFactory() |
protected org.apache.commons.pool.impl.GenericKeyedObjectPool<ConnectionKey,ConnectionPool> |
getConnectionsPool()
Gets the Pool of ConnectionPool instances which are keyed by different ConnectionKeys.
|
long |
getExpiryTimeout() |
int |
getIdleTimeout()
Gets the Idle timeout value applied to new Connection's that are created by this pool.
|
int |
getMaxConnections()
Returns the maximum number to pooled Connections that this factory will allow before it
begins to return connections from the pool on calls to (
createConnection() . |
int |
getMaximumActiveSessionPerConnection()
Returns the currently configured maximum number of sessions a pooled Connection will
create before it either blocks or throws an exception when a new session is requested,
depending on configuration.
|
int |
getNumConnections() |
long |
getTimeBetweenExpirationCheckMillis() |
void |
initConnectionsPool() |
boolean |
isBlockIfSessionPoolIsFull()
Returns whether a pooled Connection will enter a blocked state or will throw an Exception
once the maximum number of sessions has been borrowed from the the Session Pool.
|
boolean |
isCreateConnectionOnStartup() |
boolean |
isReconnectOnException() |
boolean |
isUseAnonymousProducers()
Should Sessions use one anonymous producer for all producer requests or should a new
MessageProducer be created for each request to create a producer object, default is true.
|
protected javax.jms.Connection |
newPooledConnection(ConnectionPool connection) |
protected void |
populateProperties(Properties props)
Called by any superclass that implements a JNDIReferencable or similar that needs to collect
the properties of this class for storage etc.
|
void |
setBlockIfSessionPoolIsFull(boolean block)
Controls the behavior of the internal session pool.
|
void |
setBlockIfSessionPoolIsFullTimeout(long blockIfSessionPoolIsFullTimeout)
Controls the behavior of the internal session pool.
|
void |
setConnectionFactory(Object toUse)
Sets the ConnectionFactory used to create new pooled Connections.
|
void |
setCreateConnectionOnStartup(boolean createConnectionOnStartup)
Whether to create a connection on starting this
PooledConnectionFactory . |
void |
setExpiryTimeout(long expiryTimeout)
allow connections to expire, irrespective of load or idle time.
|
void |
setIdleTimeout(int idleTimeout)
Sets the idle timeout value for Connection's that are created by this pool in Milliseconds,
defaults to 30 seconds.
|
void |
setMaxConnections(int maxConnections)
Sets the maximum number of pooled Connections (defaults to one).
|
void |
setMaximumActiveSessionPerConnection(int maximumActiveSessionPerConnection)
Sets the maximum number of active sessions per connection
|
void |
setReconnectOnException(boolean reconnectOnException)
Controls weather the underlying connection should be reset (and renewed) on JMSException
|
void |
setTimeBetweenExpirationCheckMillis(long timeBetweenExpirationCheckMillis)
Sets the number of milliseconds to sleep between runs of the idle Connection eviction thread.
|
void |
setUseAnonymousProducers(boolean value)
Sets whether a PooledSession uses only one anonymous MessageProducer instance or creates
a new MessageProducer for each call the create a MessageProducer.
|
void |
start() |
void |
stop() |
protected final AtomicBoolean stopped
protected Object connectionFactory
public PooledConnectionFactory()
public void initConnectionsPool()
public Object getConnectionFactory()
public void setConnectionFactory(Object toUse)
clear()
the pooled Connections.toUse
- The factory to use to create pooled Connections.public javax.jms.QueueConnection createQueueConnection() throws javax.jms.JMSException
createQueueConnection
in interface javax.jms.QueueConnectionFactory
javax.jms.JMSException
public javax.jms.QueueConnection createQueueConnection(String userName, String password) throws javax.jms.JMSException
createQueueConnection
in interface javax.jms.QueueConnectionFactory
javax.jms.JMSException
public javax.jms.TopicConnection createTopicConnection() throws javax.jms.JMSException
createTopicConnection
in interface javax.jms.TopicConnectionFactory
javax.jms.JMSException
public javax.jms.TopicConnection createTopicConnection(String userName, String password) throws javax.jms.JMSException
createTopicConnection
in interface javax.jms.TopicConnectionFactory
javax.jms.JMSException
public javax.jms.Connection createConnection() throws javax.jms.JMSException
createConnection
in interface javax.jms.ConnectionFactory
javax.jms.JMSException
public javax.jms.Connection createConnection(String userName, String password) throws javax.jms.JMSException
createConnection
in interface javax.jms.ConnectionFactory
javax.jms.JMSException
protected javax.jms.Connection newPooledConnection(ConnectionPool connection)
protected javax.jms.Connection createConnection(ConnectionKey key) throws javax.jms.JMSException
javax.jms.JMSException
public void start()
public void stop()
public void clear()
createConnection()
. Care should be taken when using this method as Connections that
are in use be client's will be closed.public int getMaximumActiveSessionPerConnection()
public void setMaximumActiveSessionPerConnection(int maximumActiveSessionPerConnection)
maximumActiveSessionPerConnection
- The maximum number of active session per connection in the pool.public void setBlockIfSessionPoolIsFull(boolean block)
block
- - if true, the call to getSession() blocks if the pool is full
until a session object is available. defaults to true.public boolean isBlockIfSessionPoolIsFull()
setBlockIfSessionPoolIsFull(boolean)
public int getMaxConnections()
createConnection()
.public void setMaxConnections(int maxConnections)
createConnection()
will result in a new Connection being create up to the max
connections value.maxConnections
- the maxConnections to setpublic int getIdleTimeout()
public void setIdleTimeout(int idleTimeout)
idleTimeout
- The maximum time a pooled Connection can sit unused before it is eligible for removal.public void setExpiryTimeout(long expiryTimeout)
expiryTimeout
- non zero in millisecondspublic long getExpiryTimeout()
public boolean isCreateConnectionOnStartup()
start
.public void setCreateConnectionOnStartup(boolean createConnectionOnStartup)
PooledConnectionFactory
.
This can be used to warm-up the pool on startup. Notice that any kind of exception
happens during startup is logged at WARN level and ignored.createConnectionOnStartup
- true to create a connection on startuppublic boolean isUseAnonymousProducers()
public void setUseAnonymousProducers(boolean value)
value
- Boolean value that configures whether anonymous producers are used.protected org.apache.commons.pool.impl.GenericKeyedObjectPool<ConnectionKey,ConnectionPool> getConnectionsPool()
public void setTimeBetweenExpirationCheckMillis(long timeBetweenExpirationCheckMillis)
timeBetweenExpirationCheckMillis
- The time to wait between runs of the idle Connection eviction thread.public long getTimeBetweenExpirationCheckMillis()
public int getNumConnections()
protected ConnectionPool createConnectionPool(javax.jms.Connection connection)
connection
- public long getBlockIfSessionPoolIsFullTimeout()
setBlockIfSessionPoolIsFull(boolean)
public void setBlockIfSessionPoolIsFullTimeout(long blockIfSessionPoolIsFullTimeout)
blockIfSessionPoolIsFullTimeout
- - if blockIfSessionPoolIsFullTimeout is true,
then use this setting to configure how long to block before retrypublic boolean isReconnectOnException()
public void setReconnectOnException(boolean reconnectOnException)
reconnectOnException
- Boolean value that configures whether reconnect on exception should happenprotected void populateProperties(Properties props)
props
- a properties object that should be filled in with this objects property values.Copyright © 2005–2020 FuseSource, Corp.. All rights reserved.