Class LruBoundedMessageCache
- java.lang.Object
-
- com.adaptris.core.runtime.LruBoundedMessageCache
-
- All Implemented Interfaces:
ComponentLifecycle
,MessageCache
public class LruBoundedMessageCache extends java.lang.Object implements MessageCache
A
MessageCache
implementation that uses anArrayBlockingQueue
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
log
-
Constructor Summary
Constructors Constructor Description LruBoundedMessageCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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
-
-
-
Method Detail
-
put
public void put(CacheableAdaptrisMessageWrapper message)
- Specified by:
put
in interfaceMessageCache
-
remove
public CacheableAdaptrisMessageWrapper remove(java.lang.String messageId)
- Specified by:
remove
in interfaceMessageCache
-
contains
public boolean contains(java.lang.String messageId)
- Specified by:
contains
in interfaceMessageCache
-
init
public void init()
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
-
start
public void start()
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences- Specified by:
close
in interfaceComponentLifecycle
-
getMaxMessages
public int getMaxMessages()
-
setMaxMessages
public void setMaxMessages(int maxMessages)
-
getBoundedCache
public java.util.concurrent.ArrayBlockingQueue<CacheableAdaptrisMessageWrapper> getBoundedCache()
-
setBoundedCache
public void setBoundedCache(java.util.concurrent.ArrayBlockingQueue<CacheableAdaptrisMessageWrapper> boundedCache)
-
-