public abstract class BatchingEventStorageEngine extends AbstractEventStorageEngine
AbstractEventStorageEngine
implementation that fetches events in batches from the backing database.Modifier and Type | Class and Description |
---|---|
static class |
BatchingEventStorageEngine.Builder
Abstract Builder class to instantiate a
BatchingEventStorageEngine . |
upcasterChain
Modifier | Constructor and Description |
---|---|
protected |
BatchingEventStorageEngine(BatchingEventStorageEngine.Builder builder)
Instantiate a
BatchingEventStorageEngine based on the fields contained in the BatchingEventStorageEngine.Builder . |
Modifier and Type | Method and Description |
---|---|
int |
batchSize()
Returns the maximum number of event entries to be fetched per batch.
|
protected abstract List<? extends DomainEventData<?>> |
fetchDomainEvents(String aggregateIdentifier,
long firstSequenceNumber,
int batchSize)
Returns a batch of events published by an aggregate with given
aggregateIdentifier . |
protected boolean |
fetchForAggregateUntilEmpty()
Specifies whether the
readEventData(String, long) should proceed fetching events for an aggregate until
an empty batch is returned. |
protected abstract List<? extends TrackedEventData<?>> |
fetchTrackedEvents(TrackingToken lastToken,
int batchSize)
Returns a batch of serialized event data entries in the event storage that have a
TrackingToken greater
than the given lastToken . |
protected Stream<? extends DomainEventData<?>> |
readEventData(String identifier,
long firstSequenceNumber)
Returns a
Stream of serialized event data entries for an aggregate with given identifier . |
protected Stream<? extends TrackedEventData<?>> |
readEventData(TrackingToken trackingToken,
boolean mayBlock)
Returns a global
Stream containing all serialized event data entries in the event storage that have a
TrackingToken greater than the given trackingToken . |
appendEvents, appendEvents, getEventSerializer, getSnapshotSerializer, handlePersistenceException, readEvents, readEvents, readSnapshot, readSnapshotData, storeSnapshot, storeSnapshot
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendEvents, createHeadToken, createTailToken, createTokenAt, lastSequenceNumberFor, readEvents
protected BatchingEventStorageEngine(BatchingEventStorageEngine.Builder builder)
BatchingEventStorageEngine
based on the fields contained in the BatchingEventStorageEngine.Builder
.
Will assert that the event and snapshot Serializer
are not null
, and will throw an AxonConfigurationException
if any of them is null
.
builder
- the BatchingEventStorageEngine.Builder
used to instantiate a BatchingEventStorageEngine
instanceprotected abstract List<? extends TrackedEventData<?>> fetchTrackedEvents(TrackingToken lastToken, int batchSize)
TrackingToken
greater
than the given lastToken
. Event entries in the stream should be ordered by tracking token. If the lastToken
is null
a stream containing all events should be returned.
Only if the returned List is empty the event storage assumes that the backing database holds no further applicable entries.
lastToken
- Object describing the global index of the last processed event or null
to create a
stream of all events in the storebatchSize
- The maximum number of events that should be returnedprotected abstract List<? extends DomainEventData<?>> fetchDomainEvents(String aggregateIdentifier, long firstSequenceNumber, int batchSize)
aggregateIdentifier
.
The sequence numbers in the returned batch should be ordered by sequence number. The first event in the batch
should have a sequence number equal to or larger than given firstSequenceNumber
. Implementations should
make sure the returned batch does not contain gaps between events due to uncommitted storage transactions.
If the returned number of entries is smaller than the given batchSize
it is assumed that the storage
holds no further applicable entries.aggregateIdentifier
- The identifier of the aggregate to open a stream forfirstSequenceNumber
- The sequence number of the first excepted event entrybatchSize
- The maximum number of events that should be returnedprotected boolean fetchForAggregateUntilEmpty()
readEventData(String, long)
should proceed fetching events for an aggregate until
an empty batch is returned. Defaults to false
, as Aggregate event batches typically do not have gaps in
them.boolean
specifying whether readEventData(String, long)
should proceed fetching events
for an aggregate until an empty batch is returnedprotected Stream<? extends DomainEventData<?>> readEventData(String identifier, long firstSequenceNumber)
AbstractEventStorageEngine
Stream
of serialized event data entries for an aggregate with given identifier
. The
events should be ordered by aggregate sequence number and have a sequence number starting from the given firstSequenceNumber
.readEventData
in class AbstractEventStorageEngine
identifier
- The identifier of the aggregate to open a stream forfirstSequenceNumber
- The sequence number of the first excepted event entryprotected Stream<? extends TrackedEventData<?>> readEventData(TrackingToken trackingToken, boolean mayBlock)
Stream
containing all serialized event data entries in the event storage that have a
TrackingToken
greater than the given trackingToken
. Event entries in the stream should be ordered
by tracking token. If the trackingToken
is null
a stream containing all events should be
returned.
If the end of the stream is reached and mayBlock
is true
the stream may block to wait for new
events.
This implementation produces non-blocking event streams.
readEventData
in class AbstractEventStorageEngine
trackingToken
- Object describing the global index of the last processed event or null
to create a
stream of all events in the storemayBlock
- If true
the storage engine may optionally choose to block to wait for new event
messages if the end of the stream is reached.public int batchSize()
Copyright © 2010–2022. All rights reserved.