Interface MessageHandler<T extends Message<?>>

Type Parameters:
T - The message type this handler can process
All Known Subinterfaces:
CommandMessageHandler, EventMessageHandler, Saga<T>
All Known Implementing Classes:
AggregateAnnotationCommandHandler, AnnotatedSaga, AnnotationCommandHandlerAdapter, AnnotationEventHandlerAdapter, AnnotationQueryHandlerAdapter, EventValidator

public interface MessageHandler<T extends Message<?>>
Interface for a component that processes Messages.
Since:
3.0
Author:
Rene de Waele
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canHandle(T message)
    Indicates whether this handler can handle the given message
    default boolean
    canHandleType(Class<?> payloadType)
    Indicates whether this handler can handle messages of given type
    default Class<?>
    Returns the instance type that this handler delegates to.
    handle(T message)
    Handles the given message.
  • Method Details

    • handle

      Object handle(T message) throws Exception
      Handles the given message.
      Parameters:
      message - The message to be processed.
      Returns:
      The result of the message processing.
      Throws:
      Exception - any exception that occurs during message handling
    • canHandle

      default boolean canHandle(T message)
      Indicates whether this handler can handle the given message
      Parameters:
      message - The message to verify
      Returns:
      true if this handler can handle the message, otherwise false
    • getTargetType

      default Class<?> getTargetType()
      Returns the instance type that this handler delegates to.
      Returns:
      Returns the instance type that this handler delegates to
    • canHandleType

      default boolean canHandleType(Class<?> payloadType)
      Indicates whether this handler can handle messages of given type
      Parameters:
      payloadType - The payloadType to verify
      Returns:
      true if this handler can handle the payloadType, otherwise false