I am implementing a class that will handle commands, but which is not an aggregate:
@Component
public class AxonCommandHandler {
@CommandHandler
public void handle(Rename command) throws SomeApplicationException {
....
}
}
This works as expected - the command handler method is invoked, when a Rename command is sent using the command gateway.
I would now like to add an exception handler to AxonCommandHandler, like this:
@ExceptionHandler(resultType = SomeApplicationException.class)
public void handleException() {
...
}
This does not seems to work however, as the exception handler method is not called, if a SomeApplicationException is thrown.
Am I doing something wrong? Or does the exception handler mechanism only work from an aggregate?