I am designing a CQRS application using DDD, and am wondering how to implement the following scenario:
- a
Participantaggregate can be referenced by multipleParticipantEntryaggregates - an
AddParticipantInfoCommandis issued to the Command side, which contains all info of theParticipantand oneParticipantEntry(similar to anOrderand oneOrderLineItem)
Where should the logic be implemented that checks whether the Participant already exists and if it doesn't exist, creates the Participant?
- Should it be done in a Saga that first checks the domain model for the existence of the
Participant, and if it doesn't find it, issues anAddParticipantCommandand afterwards anAddParticipantEntrycommand containing theParticipant ID? - Should this be done entirely by the aggregateroots in the domain model itself?
You don't necessarily need sagas in order to deal with this situation. Take a look at my blog post on why not to create aggregate roots, and what to do instead:
http://udidahan.com/2009/06/29/dont-create-aggregate-roots/