Annotation Interface EventHandling


Annotation to be used in favor of defining EventHandlerDefinition Beans. It can be placed on public void methods with at least one of the following unique parameter types, in any order: If placed on a method without any parameter representing EventHandlerDefinition.eventClass(), i.e. only meta-data and/or raw event, Object is used as EventHandlerDefinition.eventClass(). Hence, any such method will consume all available events.

Methods annotated using this may declare (and throw) any Throwable. As defined by EventHandlingProcessor.run() all exceptions except CqrsFrameworkException.NonTransientException will be retried automatically, if configured accordingly.

The method must be contained within an AnnotatedBeanDefinition, for instance within Components or Configurations.

EventHandling annotated methods may optionally be annotated with Transactional to enforce Spring transaction semantics for event handlers. Be aware, that these are applied per single event handling method call.

Omitting Transactional annotation does not imply, that no transaction will be active while executing the EventHandler. For instance, using JdbcProgressTracker will automatically make the handler participate in the same transaction.

This annotation may also be used within meta annotations, typically to avoid duplication of the group() for multiple methods.

See Also:
  • Element Details

    • value

      @AliasFor("group") String value
      Alias for group().
      Returns:
      the group identifier
      Default:
      ""
    • group

      @AliasFor("value") String group
      Specifies the EventHandlerDefinition.group() for the annotated method.
      Returns:
      the group identifier
      Default:
      ""