I have a CQRS system in development that passes the Command to a CommandHandler, which gets an Aggregate from a Repository, and calls a method with the properties of the Command (converted to ValueObjects).
The method then creates the Event internally and registers it in a hash object to be collected and persisted later.
I have some meta data that needs to come from the initial request and be persisted with the resulting Event, and I am loathed to have to pass this through the method on the Aggregate which IMO should be only concerned with the domain itself, and not message related data.
The problem I have is that every single public method in the domain will have to accept this meta object; that seems ridiculous to me. Even a method that normally would have no parameters (like a toggleSomeState()
method).
So, my question is, can someone provide a decent example of how the meta data can bypass the Aggregate, yet end up in the Event on the other side?
Update:
Here's an explanation of the meta data. We currently have two Uuids that have been used for authentication, and due to the nature of the domain being a multi-tenanted system, these uuids have to be persisted right the way through the application. Of course, if I have two now, I will have more later ;) This is another reason I want to not pass them into the aggregate methods.
Also, from a comment, I have learned that once an Event has been produced, it is immutable. How then could I be comfortable allowing the system to edit that Event before persistence to add this meta data? Is this one of those occasions of compromise I would have to live with?