I just wanted to ask you guys if this CQRS architecture is too complex or am I doing something wrong? So just to explain picture below:
After one bounded context emits event (SomeEventHappended = DTO) that something happened, this event is received in another bounded context.
- After Event is received in another bounded context by saga (aka process manager) and after it decides which command to issue, this event is mapped to Command message.
- After saga sends command, this command is received by Command handler. Command handler will load AggregateRoot from repository and call some method on it. Since domain method that is called expects domain objects (and not command DTO), I have to map again -> command to domain objects.
- After method on AggregateRoot is invoked and since I would like to use event sourcing, I have to map data from this domain objects to DomainEventForEventSourcing which is also new DTO. Then I can call when(DomainEventForEventSourcing event) method on AggregateRoot.
- When method reacts on DomainEvents (either when rehydrated from event store or when received for the first time) - by calling when() method, we need again to map the data, but this time between DomainEventForEventSourcing DTO and domain objects.
Just one note - I'm using pretty complex DTO's in this case and it is not just 2-3 Integer or string variables. Usually all samples keep this things simple but when you start to make real world apps, it doesn't seem so easy.
So in total 4 mappings happening each time. Maybe it is legit but maybe I'm doning somethin worng...