Method-level annotation indicating that the annotated method i an event handler method for the saga instance.
Annotated methods must comply to a few simple rules:
- The method must accept 1 parameter: a subtype of
EventMessage
- Return values are allowed, but are ignored
- Exceptions are highly
discouraged,
and are likely to be caught and ignored by the dispatchers
For each event, only a single annotated method will be invoked. This method is resolved in the following order
- First, the event handler methods of the actual class (at runtime) are searched
- If a method is found with a
parameter that the domain event can be assigned to, it is marked as eligible
- After a class has been evaluated
(but before any super class), the most specific event handler method is called. That means that if an event handler
for a class A and one for a class B are eligible, and B is a subclass of A, then the method with a parameter of type
B will be chosen
- If no method is found in the actual class, its super class is evaluated.
- If still no method
is found, the event listener ignores the event