@Documented @Retention(value=RUNTIME) @Target(value={METHOD,ANNOTATION_TYPE}) @MessageHandler(messageType=EventMessage.class) public @interface EventHandler
Axon provides a number of parameter resolvers that allow you to use the following parameter types:
@MetaDataValue
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.Instant
(or any of its super classes or implemented interfaces) 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.For each event, only a single method will be invoked per object instance with annotated methods. This method is resolved in the following order:
If you do not want any events to be ignored, but rather have some logging of the fact that an unhandled event came
by, make an abstract superclass that contains an event handler method that accepts any Object
.
Note: if there are two event handler methods accepting the same argument, the behavior is undefined.
AnnotationEventHandlerAdapter
,
ParameterResolverFactory
Modifier and Type | Optional Element and Description |
---|---|
Class<?> |
payloadType
The type of event this method handles.
|
public abstract Class<?> payloadType
Optional. If unspecified, the first parameter of the method defines the type of supported event.
Copyright © 2010–2019. All rights reserved.