@ManagedResource(description="Memory based idempotent repository") public class MemoryIdempotentRepository extends ServiceSupport implements IdempotentRepository<String>
IdempotentRepository
.
Care should be taken to use a suitable underlying Map
to avoid this class being a
memory leak.shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
MemoryIdempotentRepository() |
MemoryIdempotentRepository(Map<String,Object> set) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(String key)
Adds the key to the repository.
|
void |
clear()
Clear the repository.
|
boolean |
confirm(String key)
Confirms the key, after the exchange has been processed successfully.
|
boolean |
contains(String key)
Returns true if this repository contains the specified element.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
Map<String,Object> |
getCache() |
int |
getCacheSize() |
static IdempotentRepository<String> |
memoryIdempotentRepository()
Creates a new memory based repository using a
LRUCache
with a default of 1000 entries in the cache. |
static IdempotentRepository<String> |
memoryIdempotentRepository(int cacheSize)
Creates a new memory based repository using a
LRUCache . |
static IdempotentRepository<String> |
memoryIdempotentRepository(Map<String,Object> cache)
Creates a new memory based repository using the given
Map to
use to store the processed message ids. |
boolean |
remove(String key)
Removes the key from the repository.
|
void |
setCacheSize(int cacheSize) |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public MemoryIdempotentRepository()
public MemoryIdempotentRepository(Map<String,Object> set)
public static IdempotentRepository<String> memoryIdempotentRepository()
LRUCache
with a default of 1000 entries in the cache.public static IdempotentRepository<String> memoryIdempotentRepository(int cacheSize)
LRUCache
.cacheSize
- the cache sizepublic static IdempotentRepository<String> memoryIdempotentRepository(Map<String,Object> cache)
Map
to
use to store the processed message ids.
Care should be taken to use a suitable underlying Map
to avoid this class being a
memory leak.cache
- the cache@ManagedOperation(description="Adds the key to the store") public boolean add(String key)
IdempotentRepository
add
in interface IdempotentRepository<String>
key
- the key of the message for duplicate test@ManagedOperation(description="Does the store contain the given key") public boolean contains(String key)
IdempotentRepository
contains
in interface IdempotentRepository<String>
key
- the key of the message@ManagedOperation(description="Remove the key from the store") public boolean remove(String key)
IdempotentRepository
remove
in interface IdempotentRepository<String>
key
- the key of the message for duplicate testpublic boolean confirm(String key)
IdempotentRepository
confirm
in interface IdempotentRepository<String>
key
- the key of the message for duplicate test@ManagedOperation(description="Clear the store") public void clear()
IdempotentRepository
clear
in interface IdempotentRepository<String>
@ManagedAttribute(description="The current cache size") public int getCacheSize()
public void setCacheSize(int cacheSize)
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel