为什么CQRS存储库发布事件而不发布事件存储? [英] Why is the CQRS repository publishing events, not the event store?

查看:75
本文介绍了为什么CQRS存储库发布事件而不发布事件存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 http://cre8ivethought.com/blog/2009/11/ 12 / cqrs--la-greg-young 负责使用事件发布者发布事件的组件是存储库。

According to http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young the component responsible for publishing events using an event publisher is the repository.

我的问题很简单:为什么

My question simply is: Why is that?

在此博客中,我们被告知:

In this blog post we are told that:


域存储库负责发布事件,通常将其存储在单个事务中,并将事件存储在事件存储中。

The domain repository is responsible for publishing the events, this would normally be inside a single transaction together with storing the events in the event store.

I会期望这是事件存储的任务:一旦存储了一个(或多个)事件,它就会被发布。

I would have expected this as a task of the event store: Once an event (or multiple events) has been stored, it's published.

那为什么将它存储在存储库中?

So why is it on the repository?

推荐答案

您的域模型不知道存储机制。另一方面,无论您使用事件存储库,传统的SQL存储库还是任何其他持久性方法,都必须确保发布适当的事件。

Your domain model is unaware of the storing mechanism. On the other hand it must make sure that the appropriate events will be published, no matter if you use an event store, a classical SQL store, or any other means of persistence.

如果您依赖事件存储来发布事件,则与存储机制紧密相关。

If you rely on the event store to publish the events you'd have a tight coupling to the storage mechanism.

这篇关于为什么CQRS存储库发布事件而不发布事件存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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