如何保留查看表更新CQRS/事件采购模式

发布于 2025-02-06 03:48:46 字数 333 浏览 1 评论 0原文

使用CQRS/事件采购模式,将视图表保持最新的最佳方法是什么?

最常见的方法是通过KSQL查询,但是我想知道是否有一种更通用的方法,例如使用关系数据库。

您的应用程序运行的时间越多,您将不得不读取更多数据,从而使此数据不可持续。 您如何处理?您是否只阅读所有事件并在执行一个新命令时对它们进行计算?

What is the best way to keep a view table up to date, using the CQRS/Event Sourcing pattern?

The most common way is through KSQL queries, but I would like to know if there is a more generic way, for example, using a relational database.

enter image description here

The more time your app is running, you will have to read more data, making this unsustainable.
How do you deal with this? Do you just read all the events and compute them every time one new command is executed?

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

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

发布评论

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

评论(1

时光清浅 2025-02-13 03:48:46

典型的方法是存储在事件流中的视图状态的一部分(即偏移)。例如,您的视图可以存储事件流中某些分区(例如实体ID)的事件1003的当前。在查询该分区中的事件时,更新视图表的过程会在1003之后询问事件。一个人可以定期触发该过程,或者连续运行或作为写作命令过程的一部分发出信号。

一个观点之一可以是“将这些事件发布给卡夫卡”;在这种情况下,其他视图可以使用消费者组/偏移提交功能来处理事件,而不是一开始。

The typical approach to this is to store as part of the view's state where it is in the event stream (i.e. an offset). For example, your view can store that it's current up through event 1003 for some partition (e.g. an entity ID) in the event stream. When querying for events in that partition, the process updating the view table asks for events after 1003. One can trigger that process periodically, or have it run continuously, or signalled as part of the process of writing commands.

One of the views can be "publish these events to Kafka"; in which case other views can use the consumer group/offset commit functionality to process the events at-least-but-typically-not-more-than-once.

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