public class ReplayCache extends Object
StorageService to track information associated with messages in order to detect
message replays.
This class is thread-safe and uses a basic reentrant lock to avoid corruption of the underlying store, as well as to
prevent race conditions with respect to replay checking.| Modifier and Type | Field and Description |
|---|---|
private ReentrantLock |
cacheLock
Replay cache lock.
|
private long |
entryDuration
Time, in milliseconds, that message state is valid.
|
private org.slf4j.Logger |
log
Logger.
|
private String |
partition
Storage service partition used by this cache.
|
private StorageService<String,ReplayCacheEntry> |
storage
Backing storage for the replay cache.
|
| Constructor and Description |
|---|
ReplayCache(StorageService<String,ReplayCacheEntry> storageService,
long duration)
Constructor.
|
ReplayCache(StorageService<String,ReplayCacheEntry> storageService,
String storageParition,
long duration)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMessageID(String messageId,
org.joda.time.DateTime expiration)
Accquires a write lock and adds the message state to the underlying storage service.
|
boolean |
isReplay(String issuerId,
String messageId)
Checks if the message has been replayed.
|
private final org.slf4j.Logger log
private StorageService<String,ReplayCacheEntry> storage
private String partition
private long entryDuration
private ReentrantLock cacheLock
public ReplayCache(StorageService<String,ReplayCacheEntry> storageService, long duration)
storageService - the StorageService which serves as the backing store for the cacheduration - default length of time that message state is validpublic ReplayCache(StorageService<String,ReplayCacheEntry> storageService, String storageParition, long duration)
storageService - the StorageService which serves as the backing store for the cachestorageParition - name of storage service partition to useduration - default length of time that message state is validpublic boolean isReplay(String issuerId, String messageId)
issuerId - unique ID of the message issuermessageId - unique ID of the messageprotected void addMessageID(String messageId, org.joda.time.DateTime expiration)
messageId - unique ID of the messageexpiration - time the message state expiresCopyright © 1999-2015. All Rights Reserved.