Interface EventHandlerInvoker

All Known Implementing Classes:
AbstractSagaManager, AnnotatedSagaManager, DeadLetteringEventHandlerInvoker, MultiEventHandlerInvoker, SimpleEventHandlerInvoker

public interface EventHandlerInvoker
Interface for an event message handler that defers handling to one or more other handlers.
Since:
3.0
Author:
Rene de Waele
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canHandle(EventMessage<?> eventMessage, Segment segment)
    Check whether or not this invoker has handlers that can handle the given eventMessage for a given segment.
    default boolean
    canHandleType(Class<?> payloadType)
    Check whether or not this invoker has handlers that can handle the given payloadType.
    void
    handle(EventMessage<?> message, Segment segment)
    Handle the given message for the given segment.
    default void
    Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
    default <R> void
    performReset(R resetContext)
    Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
    default void
    This is a way for an event processor to communicate that a segment which was being processed is released.
    default boolean
    Indicates whether the handlers managed by this invoker support a reset.
  • Method Details

    • canHandle

      boolean canHandle(@Nonnull EventMessage<?> eventMessage, @Nonnull Segment segment)
      Check whether or not this invoker has handlers that can handle the given eventMessage for a given segment.
      Parameters:
      eventMessage - The message to be processed
      segment - The segment for which the event handler should be invoked
      Returns:
      true if the invoker has one or more handlers that can handle the given message, false otherwise
    • canHandleType

      default boolean canHandleType(@Nonnull Class<?> payloadType)
      Check whether or not this invoker has handlers that can handle the given payloadType.
      Parameters:
      payloadType - The payloadType of the message to be processed
      Returns:
      true if the invoker has one or more handlers that can handle the given message, false otherwise
    • handle

      void handle(@Nonnull EventMessage<?> message, @Nonnull Segment segment) throws Exception
      Handle the given message for the given segment.

      Callers are recommended to invoke canHandle(EventMessage, Segment) prior to invocation, but aren't required to do so. Implementations must ensure to take the given segment into account when processing messages.

      Parameters:
      message - The message to handle
      segment - The segment for which to handle the message
      Throws:
      Exception - when an exception occurs while handling the message
    • supportsReset

      default boolean supportsReset()
      Indicates whether the handlers managed by this invoker support a reset.
      Returns:
      true if a reset is supported, otherwise false
    • performReset

      default void performReset()
      Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
    • performReset

      default <R> void performReset(@Nullable R resetContext)
      Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
      Type Parameters:
      R - the type of the provided resetContext
      Parameters:
      resetContext - a R used to support the reset operation
    • segmentReleased

      default void segmentReleased(Segment segment)
      This is a way for an event processor to communicate that a segment which was being processed is released. This might be needed or required to free resources, are clean up state which is related to the Segment.
      Parameters:
      segment - the segment which was released.