CQRS 命令和域状态

发布于 2024-09-25 19:26:34 字数 508 浏览 0 评论 0原文

我是 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,

email

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

触ぅ动初心 2024-10-02 19:26:34

您仍然需要在写入持久性中的某个位置保留一些域数据。这样地址就存储在这个持久性存储中,事件在更改后发布。

这样:

  • 如果没有变化 - 我们可以跳过发布事件
  • 域,不需要知道有关可能(或可能不)订阅其事件的对象的任何信息。

此逻辑适用于关系数据库(例如带有 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:

  • if there were no change - we can skip publishing the event
  • domain does not need to know anything about objects that may (or may not) be subscribed to his events.

This logic applies to both persistence in relational DBs (MS SQL with NHibernate, for example) and event sourcing approach.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文