CQRS 命令和域状态
我是 CQRS 新手,对命令如何将地址更改写入客户对象感到困惑
假设我已将客户信息分为两个表
customer - 域数据库
Active Preferred
Customer_Read 数据库
姓名、
地址、
电话、
电子邮件
用户修改客户的地址。地址字段都在读取数据库中。 可能有 3 个或更多查询友好表保存地址信息。
如果我理解 CQRS 实现(示例)客户域(已删除聚合根)应该发布有关地址更改的事件,该事件应由多个处理程序处理以更新每个表。
当我不会更改客户对象的状态时,如何实现这一点? 域是否必须知道它在另一个数据库中有地址?
先感谢您。
问候,
三月
更新
- 在网上浏览了更多帖子后,我假设如果命令未更改状态,则不会生成任何事件来保存域本身,但将应用事件来更改中的地址查询/查看模型友好的表。
I am new to CQRS and confused on how command will write a address change to a customer object
Lets say I have divided customer information into two tables
customer - Domain database
Active
Preferred
Customer_Read database
Name,
Address,
Phone,
User modifies address of the customer. The address fields are all in read database.
there may be 3 or more query friendly tables that is keeping address information.
If I understand the CQRS implementations (sample) Customer Domain (removed Aggregate root) should be publishing event about address change that should be handled by multiple handlers to update each of the table.
How do I implement this when I wont be changing the state of customer object?
Do domain have to know that it has address in another database ?
Thank you in advance.
Regards,
The Mar
Update--
After going through more posts on net I am assuming that if the state is not changed by the command no event will be generated to save the domain itself but events will be applied to change the address in query / View Model friendly tables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您仍然需要在写入持久性中的某个位置保留一些域数据。这样地址就存储在这个持久性存储中,事件在更改后发布。
这样:
此逻辑适用于关系数据库(例如带有 NHibernate 的 MS SQL)中的持久性和事件源方法。
You still need to persist some domain data somewhere in the write persistence. This way the address is stored in this persistence store, event is published after changing it.
This way:
This logic applies to both persistence in relational DBs (MS SQL with NHibernate, for example) and event sourcing approach.