@EventHandler
. The declared parameters of the method define which events it will receive.@EventHandler
annotation. When specified, the first parameter is resolved using the rules specified below. Do not configure the payload type on the annotation if you want the payload to be passed as a parameter.@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 MetaData
of an EventMessage
injected.@Timestamp
and of type java.time.Instant
(or java.time.temporal.Temporal
) will resolve to the timestamp of the EventMessage
. This is the time at which the Event was generated.@SequenceNumber
and of type java.lang.Long
or long
will resolve to the sequenceNumber
of a DomainEventMessage
. This provides the order in which the Event was generated (within the scope of the Aggregate it originated from).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.@EnableAxon
on your @Configuration
file), any other parameters will resolve to autowired beans, if exactly one injectable candidate is available in the application context. This allows you to inject resources directly into @EventHandler
annotated methods.ParameterResolver
s by implementing the ParameterResolverFactory
interface and creating a file named /META-INF/service/org.axonframework.common.annotation.ParameterResolverFactory
containing the fully qualified name of the implementing class. See Advanced Customizations for details.this.getClass()
), all annotated methods are evaluatedSubListener
will be invoked for all instances of EventB
as well as EventC
(as it extends EventB
). In other words, the handler methods of TopListener
will not receive any invocations for EventC
at all. Since EventA
is not assignable to EventB
(it's its superclass), those will be processed by the handler method in TopListener
.EventHandlingConfiguration
class, which is registered as a module with the global Axon Configurer
. Typically, an application will have a single EventHandlingConfiguration
defined, but larger more modular applications may choose to define one per module.@EventHandler
methods, use the registerEventHandler
method on the EventHandlingConfiguration
: