Hi
we used Java interfaces to group certain events and used @EventHandler methods to handle the interface. This worked fine in Axon4, but in Axon5 the event handlers are simply not called.
For use it was very convenient to avoid boilerplate code by using interfaces in some projections.
This is known functionality that’s not yet implemented.
The ticket that will tackle this can be found here.
The reasoning, in short, why this doesn’t work, as because we DO NOT register handlers under the Class anymore. Not doing this provides the flexibility to adjust the business names of your events, as well as not have to rely on the FQCN of message anymore when converting them. (Thus for the latter, you can now have different concrete classes for an event between (micro)services as long as this business name is the same).
Only downside so far, is that an interface/abstract class-based event handler, well, does not have a QualifiedName to automatically works out of the box. This was “reflection magic” so to say, which we try to move to the edge.
Hence, for migration purposes, you’ll have to use concrete handlers instead for the time being.
Hi @Steven_van_Beelen
thanks for quick explanation. It’s fine for me, just wanted to understand.
Might be worth noting this somewhere in the migration docs, because this change can easily slip through during migration. Your code will migrate fine, but the EventHandler (and EventSourcingHandler) methods simply won’t be called anymore. Without explicit tests, this can easily go unnoticed. I added an ArchUnit test that detects EventHandlers using interfaces, to catch all of these cases and to stop developers from reintroducing the pattern in the future.