What’s the return type for a constructor that serves as a command handler? I don’t see anything in the documentation that calls this particular case out.
That is an interesting one as I never tried it myself.
So, after trying and digging our docs, I found it here.
To quote it:
While it is possible to return results from command handlers, this should be used sparsely. … The framework has one such exception build in, on the
@CommandHandlerannotated constructor of an Aggregate. In case the ‘command handling constructor’ has executed successfully, instead of the Aggregate itself, the value of the
@AggregateIdentifierannotated field will be returned.