Class StreamOffset
The idea a queue has no room for. A queue delivers what is there and forgets it; a stream keeps everything until retention removes it, and every consumer holds its own position. Saying where to start is therefore a normal thing to do rather than a recovery procedure, and it is what replay is.
next() is the default, and deliberately the timid one. A consumer deployed against
a stream holding a year of history and starting at first() will read the year — which
is sometimes exactly right and is never what somebody wanted by accident.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StreamOffsetat(long offset) booleanstatic StreamOffsetfirst()static StreamOffsetinthashCode()static StreamOffsetlast()static StreamOffsetstatic StreamOffsetnext()The value the broker expects as thex-stream-offsetconsumer argument.toString()
-
Method Details
-
first
- Returns:
- everything the stream still holds, oldest first
-
last
- Returns:
- the last chunk the stream holds, and everything after it. Not the same as
next(): this replays a little, because a stream is written in chunks and the last one is where the broker can cheaply seek to
-
next
- Returns:
- only messages written after this consumer attached; the default
-
at
- Parameters:
offset- the exact position to resume from, normally one past the last offset this consumer recorded as handled- Returns:
- that position
-
from
- Parameters:
timestamp- the point in time to start from- Returns:
- the first message written at or after that moment
-
lastly
- Parameters:
age- how far back to start- Returns:
- the first message written within that period, so
ofHours(1)reads the last hour and then continues
-
toConsumerArgument
The value the broker expects as thex-stream-offsetconsumer argument.Types matter here rather than only values: the broker reads a string as a keyword, a number as an absolute offset and a date as a timestamp, so a position sent as the wrong type is not rejected but silently means something else.
- Returns:
- the argument value
-
equals
-
hashCode
public int hashCode() -
toString
-