|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jms.connection.SingleConnectionFactory org.springframework.jms.connection.CachingConnectionFactory
public class CachingConnectionFactory
SingleConnectionFactory
subclass that adds Session
caching as well MessageProducer
caching. This ConnectionFactory
also switches the "reconnectOnException" property
to "true" by default, allowing for automatic recovery of the underlying Connection.
By default, only one single Session will be cached, with further requested
Sessions being created and disposed on demand. Consider raising the
"sessionCacheSize" value
in case of a
high-concurrency environment.
NOTE: This ConnectionFactory decorator requires JMS 1.1 or higher.
For JMS 1.0.2, consider using SingleConnectionFactory102
instead.
Field Summary |
---|
Fields inherited from class org.springframework.jms.connection.SingleConnectionFactory |
---|
logger |
Constructor Summary | |
---|---|
CachingConnectionFactory()
|
Method Summary | |
---|---|
protected Session |
getCachedSessionProxy(Session target,
LinkedList sessionList)
Wrap the given Session with a proxy that delegates every method call to it but adapts close calls. |
protected Session |
getSession(Connection con,
Integer mode)
Checks for a cached Session for the given mode. |
int |
getSessionCacheSize()
Return the desired size for the JMS Session cache (per JMS Session type). |
boolean |
isCacheProducers()
Return whether to cache JMS MessageProducers per JMS Session instance. |
void |
resetConnection()
Resets the Session cache as well. |
void |
setCacheProducers(boolean cacheProducers)
Specify whether to cache JMS MessageProducers per JMS Session instance (more specifically: one MessageProducer per Destination and Session). |
void |
setSessionCacheSize(int sessionCacheSize)
Specify the desired size for the JMS Session cache (per JMS Session type). |
Methods inherited from class org.springframework.jms.connection.SingleConnectionFactory |
---|
afterPropertiesSet, closeConnection, createConnection, createConnection, createQueueConnection, createQueueConnection, createTopicConnection, createTopicConnection, destroy, doCreateConnection, getClientId, getExceptionListener, getSharedConnectionProxy, getTargetConnectionFactory, initConnection, isReconnectOnException, onException, prepareConnection, setClientId, setExceptionListener, setReconnectOnException, setTargetConnectionFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachingConnectionFactory()
Method Detail |
---|
public void setSessionCacheSize(int sessionCacheSize)
This cache size is the maximum limit for the number of cached Sessions per session acknowledgement type (auto, client, dups_ok, transacted). As a consequence, the actual number of cached Sessions may be up to four times as high as the specified value - in the unlikely case of mixing and matching different acknowledgement types.
Default is 1: caching a single Session, (re-)creating further ones on demand. Specify a number like 10 if you'd like to raise the number of cached Sessions; that said, 1 may be sufficient for low-concurrency scenarios.
setCacheProducers(boolean)
public int getSessionCacheSize()
public void setCacheProducers(boolean cacheProducers)
Default is "true". Switch this to "false" in order to recreate MessageProducers on demand.
public boolean isCacheProducers()
public void resetConnection()
resetConnection
in class SingleConnectionFactory
protected Session getSession(Connection con, Integer mode) throws JMSException
getSession
in class SingleConnectionFactory
con
- the JMS Connection to operate onmode
- the Session acknowledgement mode
(Session.TRANSACTED
or one of the common modes)
null
to indicate
creation of a default Session
JMSException
- if thrown by the JMS APIprotected Session getCachedSessionProxy(Session target, LinkedList sessionList)
target
- the original Session to wrapsessionList
- the List of cached Sessions that the given Session belongs to
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |