public abstract static class ReadSideProcessor.ReadSideHandler<Event extends AggregateEvent<Event>> extends Object
This is responsible for the actual read side handling, including handling offsets and the events themselves.
Constructor and Description |
---|
ReadSideHandler() |
Modifier and Type | Method and Description |
---|---|
CompletionStage<akka.Done> |
globalPrepare()
Prepare the database for all processors.
|
abstract akka.stream.javadsl.Flow<akka.japi.Pair<Event,Offset>,akka.Done,?> |
handle()
Flow to handle the events.
|
CompletionStage<Offset> |
prepare(AggregateEventTag<Event> tag)
Prepare this processor.
|
public CompletionStage<akka.Done> globalPrepare()
This will be invoked at system startup. It is guaranteed to only be invoked once at a time across the entire cluster, and so is safe to be used to perform actions like creating tables, that could cause problems if done from multiple nodes.
It will be invoked again if it fails, and it may be invoked multiple times as nodes of the cluster go up or down. Unless the entire system is restarted, there is no way to guarantee that it will be invoked at a particular time - in particular, it should not be used for doing upgrades unless the entire system is restarted and a new cluster built from scratch.
public CompletionStage<Offset> prepare(AggregateEventTag<Event> tag)
The primary purpose of this method is to load the last offset that was processed, so that read side processing can continue from that offset.
This also provides an opportunity for processors to do any initialisation activities, such as creating or updating database tables, or migrating data.
This will be invoked at least once for each tag, and may be invoked multiple times, such as in the event of failure.
tag
- The tag to get the offset for.