CQRS sagas-我是否理解正确? [英] CQRS sagas - did I understand them right?

查看:79
本文介绍了CQRS sagas-我是否理解正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图理解传奇,同时我对它们有一种特殊的思考方式-但我不确定我是否正确。因此,我想详细说明,并让其他人告诉我它是对还是错。

I'm trying to understand sagas, and meanwhile I have a specific way of thinking of them - but I am not sure whether I got the idea right. Hence I'd like to elaborate and have others tell me whether it's right or wrong.

据我所知,sagas是如何解决问题的一种解决方案。为长期运行的流程建模。长期运行意味着:涉及多个命令,多个事件以及可能的多个聚合。

In my understanding, sagas are a solution to the question of how to model long-running processes. Long-running means: Involving multiple commands, multiple events and possibly multiple aggregates. The process is not modeled inside one of the participating aggregates to avoid dependencies between them.

基本上,一个传奇只不过是一个响应的命令/事件处理程序而已在内部和外部命令/事件上。它不包含自己的逻辑,它只是一个(有限的)状态机,因此提供诸如当事件X发生时,发送命令Y 之类的任务。

Basically, a saga is nothing more but a command / event handler that reacts on internal and external commands / events. It does not contain its own logic, it's just a (finite) state machine, and therefor provides tasks such as When event X happens, send command Y.

Sagas以及聚合都保留在事件存储中,并与特定的聚合实例相关联,因此在使用此特定聚合(或一组聚合)时会重新加载。

Sagas are persisted to the event store as well as aggregates, are correlated to a specific aggregate instance, and hence are reloaded when this specific aggregate (or set of aggregates) is used.

这是对的吗?

推荐答案

有多种实现Sagas的方法。从无状态事件处理程序到达的过程,这些事件处理程序从一路发布命令一直到承载所有状态,并且基本上是域本身的聚合。乌迪·达汉(Udi Dahan)曾经写过一篇文章,讲述了Sagas是(在他的特定情况下)正确建模的系统中唯一的聚合。我会查找并更新此答案。

There are different means of implementing Sagas. Reaching from stateless event handlers that publish commands all the way to carrying all the state and basically being the domain's aggregates themselves. Udi Dahan once wrote an article about Sagas being the only Aggregates in a (in his specific case) correctly modeled system. I'll look it up and update this answer.

还有基于文档的Sagas的概念。

There's also the concept of document-based sagas.

这篇关于CQRS sagas-我是否理解正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆