public class MongoTrackingToken extends Object implements TrackingToken
MongoEventStorageEngine to keep track of the position in an
 event stream. Order is determined by comparing timestamp, sequence number and event id.
 This tracking token implementation keeps track of all events retrieved in a period of time before the furthest position in the stream. This makes it possible to detect event entries that have a lower timestamp than that with the highest timestamp but are published at a later time (due to time differences between nodes).
| Modifier and Type | Method and Description | 
|---|---|
MongoTrackingToken | 
advanceTo(Instant timestamp,
         String eventIdentifier,
         Duration lookBackTime)
Returns a new  
MongoTrackingToken instance based on this token but which has advanced to the event with
 given timestamp, eventIdentifier and sequenceNumber. | 
boolean | 
covers(TrackingToken other)
Indicates whether this token covers the  
other token completely. | 
boolean | 
equals(Object o)  | 
Set<String> | 
getKnownEventIds()
Returns an  
Iterable with all known identifiers of events tracked before and including this token. | 
Instant | 
getTimestamp()
Get the timestamp of the last event tracked by this token. 
 | 
int | 
hashCode()  | 
TrackingToken | 
lowerBound(TrackingToken other)
Returns a token that represents the lower bound between this and the  
other token. | 
static MongoTrackingToken | 
of(Instant timestamp,
  String eventIdentifier)
Returns a new instance of a  
MongoTrackingToken with given timestamp, eventIdentifier and
 sequenceNumber for the initial event in a stream. | 
String | 
toString()  | 
TrackingToken | 
upperBound(TrackingToken other)
Returns the token that represents the furthest possible position in a stream that either this token or the given
  
other represents. | 
public static MongoTrackingToken of(Instant timestamp, String eventIdentifier)
MongoTrackingToken with given timestamp, eventIdentifier and
 sequenceNumber for the initial event in a stream.timestamp - the event's timestampeventIdentifier - the event's identifierpublic MongoTrackingToken advanceTo(Instant timestamp, String eventIdentifier, Duration lookBackTime)
MongoTrackingToken instance based on this token but which has advanced to the event with
 given timestamp, eventIdentifier and sequenceNumber. Prior events with a timestamp
 smaller or equal than the latest event timestamp minus the given lookBackTime will not be included in the
 new token.timestamp - the timestamp of the next eventeventIdentifier - the maximum distance between a gap and the token's indexlookBackTime - the maximum time between the latest and oldest event stored in the new keypublic Instant getTimestamp()
public Set<String> getKnownEventIds()
Iterable with all known identifiers of events tracked before and including this token. Note,
 the token only stores ids of prior events if they are not too old, see
 advanceTo(Instant, String, Duration).public TrackingToken lowerBound(TrackingToken other)
TrackingTokenother token. Effectively, the
 returned token will cause messages not received by both this and the other token to be redelivered.lowerBound in interface TrackingTokenother - The token to compare to this onepublic TrackingToken upperBound(TrackingToken other)
TrackingTokenother represents. Effectively, this means this token will only deliver messages that neither this, nor
 the other have been received.upperBound in interface TrackingTokenother - The token to compare this token topublic boolean covers(TrackingToken other)
TrackingTokenother token completely. That means that this token represents a
 position in a stream that has received all of the messages that a stream represented by the other token
 has received.covers in interface TrackingTokenother - The token to compare to this onetrue if this token covers the other, otherwise falseCopyright © 2010–2018. All rights reserved.