I’m doing some tests with Axon. First, I want to congratulate you for your excellent framework. It offers the possibility to understand CQRS, EventSourcing and DDD at the same time!
I want to understand how it behaves when exceptions happen in @CommandHandler methods.
I’ve observed a strange behavior when sending an async command (no answer expected) through a custom gateway (void method) when a RuntimeException occurs in the @CommandHandler method :
- when the Command Handler class does not explicitelly implements the gateway interface : no RuntimeException is thrown to the caller,
- when the Command Handler class does explictelly implements the gateway interface : the RuntimeException is thrown to the caller.
With an aync method, I guess the first case should be the normal one: no result is expected at all by the caller (even an Exception).
BTW, this is what I’ve observed when sending the same command through the CommandBus dispatch method.
Hence my questions :
- should a Command Handler class implements its custom gateway ? In my understanding, it should since it enforces the code consistency at the compiler level,
- why does it change the behavior on the caller side when a RuntimeException is thrown by the Command Handler method ?
If my explanations are not clear enough, I can send a very basic Java project.
I’m using Axon 2.2 and the SImpleCommandBus implementation.