Annotation Interface CommandHandler


Marker annotation to mark any method on an object as being a CommandHandler. Use the AnnotationCommandHandlerAdapter to subscribe the annotated class to the command bus. This annotation can also be placed directly on Aggregate members to have it handle the commands directly.

The annotated method's first parameter is the command handled by that method. Optionally, the command handler may specify a second parameter of type UnitOfWork. The active Unit of Work will be passed if that parameter is supplied.

Since:
0.5
Author:
Allard Buijze
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the Command this handler listens to.
    The type of payload expected by this handler.
    The property of the command to be used as a routing key towards this command handler instance.
  • Element Details

    • commandName

      String commandName
      The name of the Command this handler listens to. Defaults to the fully qualified class name of the payload type (i.e. first parameter).
      Returns:
      The command name
      Default:
      ""
    • routingKey

      String routingKey
      The property of the command to be used as a routing key towards this command handler instance. If multiple handlers instances are available, a sending component is responsible to route commands with the same routing key value to the correct instance.
      Returns:
      The property of the command to use as routing key
      Default:
      ""
    • payloadType

      Class<?> payloadType
      The type of payload expected by this handler. Defaults to the expected types expresses by (primarily the first) parameters of the annotated Method or Constructor.
      Returns:
      the payload type expected by this handler
      Default:
      java.lang.Object.class