Hi all,
I'am reading a lot into CQRS and DDD but cant exactly pinpoint what I should/could use to transform external requests (from a existing legacay application) into a domain command.
Take for example a traffic light system. It would be nice if our system received an external message like "ChangedToRedEvent". This would then be a command for our system on which to act and execute some business logic which results in a new Event on our side. Instead of receiving a change in state we receive the complete denormalized current state of the traffic light, let's say => "Red=false, Yellow=false, Green=true"
If you wanted to build a CQRS application, where do you transform the incoming "Red=false, Yellow=false, Green=true" into ChangedToRedEvent??
My current guess is that i need to create some sort of Domain Service which access the read side which should offer the last received state (probably in the same format) to determine what is changed. That way the domain service could derive (create) the command from the external messages.
So an CQRS/event sourced application flow would then be something like:
1. Receive message on incoming adapter
2. Domain service queries read side for any relevant information to derive a command.
3. Handle the command based and create an event based on the domain rules
4. Post the event
5. Handle the event (Update read side projections, etc...)
Any thoughts?
Joost