Interface ResetHandler

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.

@FunctionalInterface public interface ResetHandler extends MessageHandler
Functional interface for handling ResetContext messages.

Implementations of this interface process reset notifications, typically to prepare for event replay by cleaning up the projection state, clearing caches, or performing other reset-related operations.

Reset handlers are registered via ResetHandlerRegistry.subscribe(ResetHandler).

Example usage:


 ResetHandler handler = (resetContext, context) -> {
     repository.deleteAll();
     cache.clear();
     return MessageStream.empty();
 };
 
Since:
5.0.0
Author:
Mateusz Nowak
See Also:
  • Method Details

    • handle

      MessageStream.Empty<Message> handle(ResetContext resetContext, ProcessingContext context)
      Handles the given ResetContext message, performing any necessary reset operations.

      This method is invoked before the processor begins replaying events. Handlers typically use this opportunity to clean up state that will be rebuilt during replay.

      If this method completes exceptionally, the reset operation will be aborted and no replay will occur.

      Parameters:
      resetContext - The reset context message containing reset information and optional payload.
      context - The processing context for this operation.
      Returns:
      An empty message stream after handling completes successfully.