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 |
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() |
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() |
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)
.Copyright © 2010–2017. All rights reserved.