Interface EventHandlingComponent

All Superinterfaces:
DescribableComponent, EventHandler, MessageHandler, ReplayStatusChangedHandler, ResetHandler
All Known Implementing Classes:
AnnotatedEventHandlingComponent, DeadLetteringEventHandlingComponent, DelegatingEventHandlingComponent, InterceptingEventHandlingComponent, ReplayBlockingEventHandlingComponent, SequenceCachingEventHandlingComponent, SequenceOverridingEventHandlingComponent, SequencingEventHandlingComponent, SimpleEventHandlingComponent, TracingEventHandlingComponent

public interface EventHandlingComponent extends EventHandler, ResetHandler, ReplayStatusChangedHandler, DescribableComponent
Interface describing a group of EventHandlers belonging to a single component.

As such, it allows registration of EventHandlers through the EventHandlerRegistry. Besides handling and registration, it specifies which events it supports.

Additionally, this component supports reset operations through the ResetHandler. The supportsReset() method indicates whether the component can participate in replay operations.

Since:
3.0.0
Author:
Rene de Waele, Steven van Beelen
  • Method Details

    • supportedEvents

      Set<QualifiedName> supportedEvents()
      All supported events, referenced through a QualifiedName.
      Returns:
      All supported events, referenced through a QualifiedName.
    • supports

      default boolean supports(QualifiedName eventName)
      Checks whether the given eventName is supported by this component.
      Parameters:
      eventName - The name of the event to check for support.
      Returns:
      true if the given eventName is supported, false otherwise.
    • sequenceIdentifierFor

      Object sequenceIdentifierFor(EventMessage event, ProcessingContext context)
      Returns the sequence identifier for the given event. When two events have the same sequence identifier (as defined by their equals method), they will be executed sequentially. Important: All EventHandlers for the same QualifiedName within a single EventHandlingComponent must return the same sequence identifier for a given event. Mixing different sequence identifiers within the scope of a single EventHandlingComponent is not supported and may lead to undefined behavior.
      Parameters:
      event - The event for which to get the sequencing identifier.
      context - The processing context in which the event is being handled.
      Returns:
      A sequence identifier for the given event.
    • supportsReset

      default boolean supportsReset()
      Indicates whether this component supports reset operations.

      When true, this component can participate in replay operations and its ResetHandler.handle(ResetContext, ProcessingContext) method will be called before replay begins.

      By default, reset is supported.

      Returns:
      true if this component supports reset operations, false otherwise.
    • handle

      default MessageStream.Empty<Message> handle(ReplayStatusChanged statusChange, ProcessingContext context)
      Description copied from interface: ReplayStatusChangedHandler
      Handles the given ReplayStatusChanged message, allowing for tasks to be performed when the replay starts and ends.

      This method is invoked on the moment the ReplayStatus is about to change as part of the event handling ProcessingContext. In doing so, this handler has two concrete moments when it is invoked:

      1. When the ReplayStatus changes from ReplayStatus.REGULAR to ReplayStatus.REPLAY, exactly before the first replayed event is processed
      2. When the ReplayStatus changes from ReplayStatus.REPLAY to ReplayStatus.REGULAR, exactly after processing the final event of the replay

      If this operation returns a failed MessageStream, event handling that occurs within the given context is impacted. The failure will be passed to the ErrorHandler, typically resulting in a rollback of the invoked event handling tasks.

      Specified by:
      handle in interface ReplayStatusChangedHandler
      Parameters:
      statusChange - the replay status context message containing replay status information
      context - the processing context for this operation
      Returns:
      an empty message stream after handling completes successfully