Firts off, congratulation for the very good done job with Axon V3. I’ve started playing around with it and it is a pleasure.
BTW, I hope the best for Allard and the Axon Dev team in 2018.
I have a question regarding the way to implement contextual business logic. I fully agree with the principle to put CommandHandler methods in Aggegrates but I find it a bit limitating when contextual business logic is needed.
Let’s take a concrete example: considering the Complaint management system from the “Bootiful CQRS Webinar with Axon”, what if I want to check that the company is known (against some reference data) while processing a FileComplaintCommand?
I’ve identified the following options to implement the check:
in the Complaint Aggregate itself: it doesn’t sound good in terms of design, creating a dependency on some external reference data breaks the separation of concerns and make the Aggregate hard to unit test,
in a dedicated CommandHandler in front of the Aggregate: may be better in terms of design but heavy to implement since 2 commands are needed (one for the check, and one for the creation of the Aggregate),
in a CommandHandlerInterceptor: may be technically feasible but I don’t think that such interceptors are intented to implement business logic. I would tend to use them for non functional requirements such as security,
in a standard Java class (such as one annotated with @Service using Spring) in front of the Aggregate: that class would act as an intermediate between the REST interface and the Aggregate,
In my opinion, the 4th option is better. Am I right? Any advice, feedback or good practise would be very appreciated