Hello Allard,
What are your recommendations to check for existence of aggregate root instances by business key? For example, when creating a user, one might want to check that the loginId is not taken already.
A few options:
- The client application makes sure that the loginId doesn’t exist by querying the read side
- The command handler checks for existence by querying the read side
Placing responsibility on the client seems a bit irresponsible. However, in a highly concurrent system, two users might try to create the same loginId or the same user might press the submit button more than once, and if the read side has not updated yet, the second attempt might erroneously succeed as well.
How are others dealing with such issues?
Thanks!
Prem