Annotation Interface EventHandling
EventHandlerDefinition
Bean
s. It can be placed on public void
methods with at least
one of the following unique parameter types, in any order:
- any non-primitive class extending
Object
(includingObject
itself) representing an assignableEventHandlerDefinition.eventClass()
- a
java.util.Map<String, ?>
for the event meta-data - an
Event
for the raw event - any number of
Autowired
annotated parameters, resolving to single beans within theApplicationContext
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
Component
s or Configuration
s.
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:
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
Alias forgroup()
.- Returns:
- the group identifier
- Default:
""
-
group
Specifies theEventHandlerDefinition.group()
for the annotated method.- Returns:
- the group identifier
- Default:
""
-