CQRS - 消费事件服务

发布于 2024-09-12 19:44:24 字数 202 浏览 4 评论 0原文

我的问题是关于订阅 CQRS 中命令发布的事件的消费事件服务。

假设我有一个文档生成服务,它将根据某些事件生成一些文档,文档生成服务是否通过聚合根从域加载数据?如果是这样,文档生成服务是否不会加载可能已在生成服务接收到的事件之后更新的数据?你会如何阻止这种情况发生?

我想我假设事件只会传递命令 DTO 收到的信息,并将整个域模型数据传递给事件感觉非常错误。

My question is regarding the consuming event services which subscribes to the event published by commands in CQRS.

Say I have a document generation service which will generate some documents based on certain events, does the document generation service load the data from the domain via an aggregate root? If so, wouldn't the document generation service load data which may have been updated subsequently of the event being received by the generation service? How would you stop that from happening?

I guess I am assuming that the event will only pass the information received by command DTO and passing the whole domain model data to the event feels very wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

哎呦我呸! 2024-09-19 19:44:25

我只能说,当你在cqrs中发言时,你应该更深入地描述问题,以便正确地解决或提供帮助。

然而,据我所知,您可以在写入端拥有持久存储,但要确保不会超出聚合上下文。
相关问题 read-data-from-database-on-write-侧入 cqrs

All i can say is that when you are speaking in cqrs you should describe the issue more deeply to solve or provide help to it properly.

However from what I've read is that you can have persistent storage on your write side, but ensure that you are not reaching out of your aggregate context.
Related issue reading-data-from-database-on-write-side-in-cqrs

如梦亦如幻 2024-09-19 19:44:24

您确实应该根据事件构建读取模型,除非您认为文档是域的一部分(并且您将有一个 CreateDocumentX 命令)

You really should build your read model from your events, unless you consider your documents a part of the domain (and you would have a CreateDocumentX command)

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