Closed paulkre closed 11 months ago
Maybe there needs to be a third aggregate containing the shared state between the first two aggregates?
If I understand correctly, you are trying to modify two aggregates and you'd like to have an atomic commit for both? If this is going to be common with your aggregates, you might want to consider you need to incorporate the logic of both into a larger aggregate.
An aggregate always should be an entity, but not all entities need to be an aggregate. E.g., you could have a Customer and an Account aggregate, but if the business rules lock them together it might be better to have a single CustomerAccount aggregate.
Context might help to understand what the reasoning is here, feel free to start a discussion on this.
I added some context here: https://github.com/serverlesstechnology/cqrs/discussions/86
If the server crashes right after executing the first line, only the aggregate of
cqrs_a
will be in the correct state and the state ofcqrs_b
's aggregate will be incorrect. Is there some way of ensuring that the resultant events of both commands are either all commited, if both commands succeed, or all dropped, if one of the commands fails?