Class CachedDestinationJndiImplementation
- java.lang.Object
-
- com.adaptris.core.jms.VendorImplementationImp
-
- com.adaptris.core.jms.jndi.BaseJndiImplementation
-
- com.adaptris.core.jms.jndi.StandardJndiImplementation
-
- com.adaptris.core.jms.jndi.CachedDestinationJndiImplementation
-
- All Implemented Interfaces:
ComponentLifecycleExtension
,ConnectionComparator<VendorImplementationBase>
,VendorImplementation
,VendorImplementationBase
public class CachedDestinationJndiImplementation extends StandardJndiImplementation
Extension ofStandardJndiImplementation
that caches destinations in between calls.This cache is preserved across normal component lifecycle; e.g. the cache remains even if you invoke
Channel.requestClose()
and thenChannel.requestStart()
. The only way to reset the cache is to create a new instance. If thisVendorImplementation
is used as part of aStandaloneProducer
then the cache is preserved across the component lifecycles. If used as part of aRetryOnceStandaloneProducer
then the cache will be reset when underlying components is restarted (this producer specifically marshal/unmarshal it's components).- See Also:
StandardJndiImplementation
In the adapter configuration file this class is aliased as cached-destination-jndi-implementation which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,javax.jms.Queue>
queues
protected java.util.Map<java.lang.String,javax.jms.Topic>
topics
-
Fields inherited from class com.adaptris.core.jms.jndi.BaseJndiImplementation
context, jndiName
-
Fields inherited from class com.adaptris.core.jms.VendorImplementationImp
log
-
-
Constructor Summary
Constructors Constructor Description CachedDestinationJndiImplementation()
CachedDestinationJndiImplementation(int cacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.jms.Queue
createQueue(java.lang.String name, JmsActorConfig c)
Checks to see if the queue cache contains the provided name.javax.jms.Topic
createTopic(java.lang.String name, JmsActorConfig c)
Checks to see if the topic cache contains the provided name.java.lang.Integer
getMaxDestinationCacheSize()
Get the max number of entries in the cache.int
maxDestinationCacheSize()
void
setMaxDestinationCacheSize(java.lang.Integer maxSize)
Set the max number of entries in the cache.-
Methods inherited from class com.adaptris.core.jms.jndi.StandardJndiImplementation
createConnectionFactory
-
Methods inherited from class com.adaptris.core.jms.jndi.BaseJndiImplementation
asList, connectionEquals, enableEncodedPasswords, getEnableEncodedPasswords, getEncodedPasswordKeys, getExtraFactoryConfiguration, getJndiName, getJndiParams, getNewContextOnException, getUseJndiForQueues, getUseJndiForTopics, lookup, newContextOnException, retrieveBrokerDetailsForLogging, setEnableEncodedPasswords, setEncodedPasswordKeys, setExtraFactoryConfiguration, setJndiName, setJndiParams, setNewContextOnException, setUseJndiForQueues, setUseJndiForTopics, useJndiForQueues, useJndiForTopics
-
Methods inherited from class com.adaptris.core.jms.VendorImplementationImp
applyVendorSessionProperties, createConsumer, createDestination, createQueueReceiver, createSession, createTopicSubscriber, prepare
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycleExtension
prepare
-
Methods inherited from interface com.adaptris.core.jms.ConnectionComparator
connectionEquals
-
Methods inherited from interface com.adaptris.core.jms.VendorImplementation
createConnection
-
Methods inherited from interface com.adaptris.core.jms.VendorImplementationBase
createConsumer, createDestination, createQueueReceiver, createSession, createTopicSubscriber, retrieveBrokerDetailsForLogging
-
-
-
-
Method Detail
-
createQueue
public javax.jms.Queue createQueue(java.lang.String name, JmsActorConfig c) throws javax.jms.JMSException
Checks to see if the queue cache contains the provided name. If so it returns the cached queue. Otherwise, looks the queue up from JNDI and stores it in the cache for future use, before returning it.- Specified by:
createQueue
in interfaceVendorImplementationBase
- Overrides:
createQueue
in classBaseJndiImplementation
- Parameters:
name
- the name of the queuec
- the Configuration- Returns:
- a
Queue
object - Throws:
javax.jms.JMSException
- if any occur- See Also:
BaseJndiImplementation.createQueue(java.lang.String, JmsActorConfig)
-
createTopic
public javax.jms.Topic createTopic(java.lang.String name, JmsActorConfig c) throws javax.jms.JMSException
Checks to see if the topic cache contains the provided name. If so it returns the cached topic. Otherwise, looks the topic up from JNDI and stores it in the cache for future use, before returning it.- Specified by:
createTopic
in interfaceVendorImplementationBase
- Overrides:
createTopic
in classBaseJndiImplementation
- Parameters:
name
- the name of the topicc
- the Configuration- Returns:
- a
Topic
object - Throws:
javax.jms.JMSException
- if any occur- See Also:
BaseJndiImplementation.createTopic(java.lang.String, JmsActorConfig)
-
getMaxDestinationCacheSize
public java.lang.Integer getMaxDestinationCacheSize()
Get the max number of entries in the cache.- Returns:
- the maximum number of entries.
-
setMaxDestinationCacheSize
public void setMaxDestinationCacheSize(java.lang.Integer maxSize)
Set the max number of entries in the cache.Entries will be removed on a least recently accessed basis.
- Parameters:
maxSize
- the maximum number of entries, default 16
-
maxDestinationCacheSize
public int maxDestinationCacheSize()
-
-