There are several ways to read messages from SQL Stream Store.
Read All
The 'all' stream is a virtual stream over all messages in SQL Stream Store,
ordered by their written Position
. There are two ways of reading the 'all'
stream, forwards and backwards.
Backwards The method to read the 'all' stream backwards is:
Task<ReadAllPage> ReadAllBackwards(
long fromPositionInclusive,
int maxCount,
bool prefetchJsonData,
CancellationToken cancellationToken = default)
fromPositionInclusive
is anInt64
that specifies where to start reading from. UsePosition.End
to start reading backwards from the end.maxCount
is anInt32
to specify the page size of the read.prefetchJsonData
is aBoolean
that specifies whether or not to preload the message data.- The
ReadAllPage
contains several properties to give the caller information about what was read.Messages
are the messages in this read.FromPosition
represents where this page was read from.NextPosition
indicates where the next page should be read from.IsEnd
indicates if this is the last page to read, i.e., are there no more messages to read.Direction
indicates which direction the 'all' stream was read in, in this caseReadDirection.Backwards
. Finally, there is a methodReadNext
which simply returns the next page.
Backwards The method to read the 'all' stream forwards is:
Task<ReadAllPage> ReadAllForwards(
long fromPositionInclusive,
int maxCount,
bool prefetchJsonData,
CancellationToken cancellationToken = default)
fromPositionInclusive
is anInt64
that specifies where to start reading from. UsePosition.Start
to start reading forwards from the first message.maxCount
is anInt32
to specify the page size of the read.prefetchJsonData
is aBoolean
that specifies whether or not to preload the message data.- The
ReadAllPage
contains several properties to give the caller information about what was read.Messages
are the messages in this read.FromPosition
represents where this page was read from.NextPosition
indicates where the next page should be read from.IsEnd
indicates if this is the last page to read, i.e., are there no more messages to read.Direction
indicates which direction the 'all' stream was read in, in this caseReadDirection.Forwards
. Finally, there is a methodReadNext
which simply returns the next page.