|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Documented @Retention(value=RUNTIME) @Target(value=METHOD) public @interface EventHandler
Annotation to be placed on methods that can handle events. The parameters of the annotated method are resolved using parameter resolvers.
Axon provides a number of parameter resolvers that allow you to use the following parameter types:@MetaData
will resolve to the Meta Data value with the key as indicated
on the annotation. If required is false (default), null is passed when the meta data value is not present. If
required is true, the resolver will not match and prevent the method from being invoked when the meta data value is
not present.MetaData
will have the entire Meta Data of an Event Message
injected.DateTime
(or any of its super classes or implemented interfaces)
annotated with @Timestamp
will resolve to the timestamp of the EventMessage. This is the time at
which the Event was generated.Message
will have the entire EventMessage
injected (if the message is assignable to that parameter). If the first
parameter is of type message, it effectively matches an Event of any type, even if generic parameters would suggest
otherwise. Due to type erasure, Axon cannot detect what parameter is expected. In such case, it is best to declare a
parameter of the payload type, followed by a parameter of type Message.<axon:annotation-config/>
is declared, any other parameters will
resolve to autowired beans, if exactly one autowire candidate is available in the application context. This allows
you to inject resources directly into @EventHandler
annotated methods.Object
.
Note: if there are two event handler methods accepting the same argument, the behavior is undefined.
AnnotationEventListenerAdapter
,
ParameterResolverFactory
Optional Element Summary | |
---|---|
Class<?> |
eventType
The type of event this method handles. |
public abstract Class<?> eventType
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |