I’m currently developing a stock management software and that’s my first
try with Axon framework, and CQRS design in general.
So far, I have two aggregates root :
For both, I’m using a Event Sourcing repository.
I’ve implemented some commands to handle some common business processes
like checkIn, and some other that are specific to my business field (grade
item, and so on…).
These command are applied to the WarehouseItem only, but now, I have to
implement a new use case about TransferOrder.
Basically (and obviously), we can add warehouse items to the TransferOrder.
But these items can only be selected if the item is available according to
certain business conditions.
So, I have a command AddWarehouseItemToTransferOrder with the warehouse
I can see two solutions to check if the warehouse item is available :
- Perform the check in the CommandHandler of this command by loading the
WarehouseItem aggregate id from there.
- Use a Saga to perform the check later on using the
WarehouseItemAddedEvent, and implement a LockItemCommand on WarehouseItem
aggregate that would fail if the item is not available.
What is twisting my mind about 1) is that it would imply that from the same
CommandHandler, I would load the TransferOrder and WarehouseItem
aggregates. I never saw such a case in all examples I’ve seen so far, so is
it supposed to be a bad practice ? Should I have another service that would
rely on a specific “View” data generated from the WarehouseItem Events to
know if it’s available ?
- seems to be cumbersome for my use case but has the advantage not to mix
Thank you for your help, ideas, suggestions…