Inheritance with command Handler

Design question…

have BaseCommandHandler

class BaseHandler {

Public void (ACommand command){

class InheritedBaseHandler extends BaseHandler
class InheritedBaseHandler2 extends BaseHandler

Can you route ACommand to InheritedBaseHandler OR InheritedBaseHandler2 when doing commandbus.dispatch(new ACommand())…

Thoughts? Ideas?

Thanks and Cheers…


in the current implementation, the last command handler instance registered with the Command Bus will get the commands. If the method is the same in both instances (i.e. none of the subclasses overrides it), this should already work fine.



The problem is that the abstract method uses different repository with generics, hence wrong repository gets picked up. Need to pick up correct concrete impl based on generic data type of impl.. Any thoughts? Realize that generic data type matching may be a challenge in picking correct handler.

Thx and Cheers...

How could Axon know the type of aggregate a specific command instance is targeting? Sounds like the aggregates should either have a shared superclass on which the Command will execute, or you need two different commands altogether.