public class LruBoundedMessageCache extends java.lang.Object implements MessageCache
A MessageCache
implementation that uses an ArrayBlockingQueue
to hold the messages.
Once the internal queue reaches it's limit, the oldest message will be removed and the newer message added.
You can control the limit of the internal queue by configuring "max-messages".
In the adapter configuration file this class is aliased as lru-bounded-message-cache which is the preferred alternative to the fully qualified classname when building your configuration.
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
Constructor and Description |
---|
LruBoundedMessageCache() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the component.
|
boolean |
contains(java.lang.String messageId) |
java.util.concurrent.ArrayBlockingQueue<CacheableAdaptrisMessageWrapper> |
getBoundedCache() |
int |
getMaxMessages() |
void |
init()
Initialises the component.
|
void |
put(CacheableAdaptrisMessageWrapper message) |
CacheableAdaptrisMessageWrapper |
remove(java.lang.String messageId) |
void |
setBoundedCache(java.util.concurrent.ArrayBlockingQueue<CacheableAdaptrisMessageWrapper> boundedCache) |
void |
setMaxMessages(int maxMessages) |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
public void put(CacheableAdaptrisMessageWrapper message)
put
in interface MessageCache
public CacheableAdaptrisMessageWrapper remove(java.lang.String messageId)
remove
in interface MessageCache
public boolean contains(java.lang.String messageId)
contains
in interface MessageCache
public void init()
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
public void start()
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
start
in interface ComponentLifecycle
public void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
stop
in interface ComponentLifecycle
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
close
in interface ComponentLifecycle
public int getMaxMessages()
public void setMaxMessages(int maxMessages)
public java.util.concurrent.ArrayBlockingQueue<CacheableAdaptrisMessageWrapper> getBoundedCache()
public void setBoundedCache(java.util.concurrent.ArrayBlockingQueue<CacheableAdaptrisMessageWrapper> boundedCache)