The @EventHandler javadoc neatly drops this interesting tidbit at it’s conclusion:
Note: if there are two event handler methods accepting the same argument, the behavior is undefined.
My colleague and I are unsure whether this applies only to two methods defined in the same class, or rather to two methods, no matter where either is defined? I stumbled upon this note when looking for a way to enforce the order in which two such methods would be triggered and now I am a bit panicked
there are rules that ensure which handlers are invoked when. Basically, it starts with the subclass (actual instance type) to find a handler there, moving up in the class hierarchy if it can’t find one. If, at the same hierarchical level, there are two handlers, Axon will choose the most specific one.
Only when two signatures are identical or equal is ‘specificness’, it will just pick one.
Thanks for the quick reply, Allard, however I am afraid I can still interpret your answer in both ways.
Let me clarify with a code example.
`
public final class ThunderStruckEvent {}
public final class BritneyDidItAgainEvent {}
@Named
public class ConcertReviewer { @EventHandler
public void postReviewByAllard(BritneyDidItAgainEvent e) {…}
@EventHandler
public void postReviewByPieter(BritneyDidItAgainEvent e) {…}
@EventHandler
public void postReviewByThirdPerson(ThunderStruckEvent e) {…}
}
@Named
public class ChickenCoop { @EventHandler
public void startPanicking(ThunderStruckEvent e) {…}
}
`
Does the mentioned undefined behaviour apply to only the postReviewByAllard and postReviewByPieter methods, or does it also apply to the postReviewByThirdPerson and startPanicking methods?