Interface ReplayStatusChangedHandler
- All Superinterfaces:
MessageHandler
- All Known Subinterfaces:
EventHandlingComponent
- All Known Implementing Classes:
AnnotatedEventHandlingComponent,DeadLetteringEventHandlingComponent,DelegatingEventHandlingComponent,InterceptingEventHandlingComponent,ReplayBlockingEventHandlingComponent,SequenceCachingEventHandlingComponent,SequenceOverridingEventHandlingComponent,SequencingEventHandlingComponent,SimpleEventHandlingComponent,TracingEventHandlingComponent
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ReplayStatusChanged messages.
Implementations of this interface process replay status changes, typically to prepare for and finalize an event
replay. Actions to consider during a ReplayStatus change are cleaning up the projection state, clearing
caches, or switching storage solution aliases. To that end, the ReplayStatusChange message contains the
ReplayStatus changed to.
Replay status change handlers are registered via
ReplayStatusChangedHandlerRegistry.subscribe(ReplayStatusChangedHandler).
Example usage:
ReplayStatusChangeHandler handler = (statusChange, context) -> {
if (statusChange.status() == REPLAY) {
repository.deleteAll();
cache.clear();
}
return MessageStream.empty();
};
- Since:
- 5.1.0
- Author:
- Simon Zambrovski, Stefan Dragisic, Steven van Beelen
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionhandle(ReplayStatusChanged statusChange, ProcessingContext context) Handles the givenReplayStatusChangedmessage, allowing for tasks to be performed when thereplay startsandends.
-
Method Details
-
handle
Handles the givenReplayStatusChangedmessage, allowing for tasks to be performed when thereplay startsandends.This method is invoked on the moment the
ReplayStatusis about to change as part of the event handlingProcessingContext. In doing so, this handler has two concrete moments when it is invoked:- When the
ReplayStatuschanges fromReplayStatus.REGULARtoReplayStatus.REPLAY, exactly before the first replayed event is processed - When the
ReplayStatuschanges fromReplayStatus.REPLAYtoReplayStatus.REGULAR, exactly after processing the final event of the replay
If this operation returns a
failed MessageStream, event handling that occurs within the givencontextis impacted. The failure will be passed to theErrorHandler, typically resulting in a rollback of the invoked event handling tasks.- Parameters:
statusChange- the replay status context message containing replay status informationcontext- the processing context for this operation- Returns:
- an empty message stream after handling completes successfully
- When the
-