This question is related, but more specific than this question.
I'm going to use a simple example here. Say we have a User
entity in one context and a Customer
entity in another context. These are 2 different representations of the same entity.
Let's say the User
and Customer
both have an email address, but the email address is always changed via the bounded context that the User
belongs to. So the user context is the source of truth for the email address. So ideally I would like the email address in the Customer
context to be immutable from the point of view of the customer context.
So when the email address is changed in the user context, an EmailAddressChanged
event is emitted. This is fine; I subscribe to the event in the Customer
context. However, I now need to handle this event by mutating the Customer
email address. So I need some sort of command method to make this change.
How can I ensure that the command method is not used, other than when handling the event from the User
context?
If I allow mutation in both contexts then they both become sources of truth and I need double the number of events and handlers to ensure that the information remains consistent in both contexts