哪一层用于领域事件、事件处理程序、调度程序

发布于 2024-09-27 11:01:00 字数 1284 浏览 5 评论 0原文

我一直在阅读有关域事件的内容,并且看到了 Udi 实现中的代码(http://www.udidahan.com/2009/06/14/domain-events-salvation/) ,迈克·哈德洛 (http://mikehadlow.blogspot.com /2010/09/separation-of-concerns-with-domain.html),Jimmy Bogard 和 Jason Dentler 的实现。

总而言之,我喜欢事件的想法。

我的问题是我应该在哪一层添加这些组件。

我不会使用任何总线,并且所有事件都将以同步方式处理

我想接口 IDomainEvent 、 IEventHandler 应该放在 Project.Core 中,其中其余接口由所有项目保留和访问。

我认为调度程序(这是一个静态类)应该进入Project.Infrastruct

我将仅为域事件处理程序创建一个新项目。可以说Project.EventHandlers

我将使用 IoC(结构图)来注册所有处理程序。

我所看到的事件本身是基于业务语言的,因此我认为应该转到实现所有聚合的 Project.Domain

让我知道这是否是正确的方法。

我的另一个困惑是项目参考。 Project.Domain 应该引用 Project.Infrastruct,以便它可以使用静态事件调度程序

Project.EventHandlers 应该引用 Project.Domain 因为它需要知道可以处理哪些事件。

我计划在 Project.EventHandlers 中创建一个 StructureMap 注册表类,然后将其引导到 Global.asax 中。

如果之前已经讨论过这个问题,请给我指向链接。我通过 Google 搜索找不到。

I have been reading about Domain Events and have seen codes from Udi's implementation(http://www.udidahan.com/2009/06/14/domain-events-salvation/)
,Mike Hadlow (http://mikehadlow.blogspot.com/2010/09/separation-of-concerns-with-domain.html), Jimmy Bogard and Jason Dentler's implementation.

All in all I like the idea of events.

My questions is which layer should I add these components.

I am not going to use any BUS and all events will be handled in Synchronous fashion.

I guess the interface IDomainEvent , IEventHandler should go in Project.Core where rest of the interfaces are kept and accessed by all projects.

The Dispatcher (which is a static class) I believe should go into Project.Infrastructure.

I will create a new Project just for Handlers of domain events. lets say Project.EventHandlers.

I will use IoC (structuremap) to register all handlers.

The Events themselves as I see are based on Business Language and for that reason I believe should go to Project.Domain where all Aggregates are implemented.

Let me know if this is the right way.

My other confusion is on project references. Should Project.Domain reference Project.Infrastructure so that it can use the static Event Dispatcher.

Should Project.EventHandlers reference Project.Domain because It needs to know what events are there that can be handled.

I am planning to create a StructureMap Registry class in Project.EventHandlers that will be then BootStrapped in Global.asax.

If this has been talked before please point me to the link. I couldn't find one through Google Searches.

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

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

发布评论

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

评论(1

日暮斜阳 2024-10-04 11:01:00

这些是项目还是命名空间?关于细粒度和粗粒度的项目结构存在着一场古老而持续的争论。我属于粗粒度阵营。程序集是部署单元,而不是逻辑层,您所描述的结构最好作为单个项目中的命名空间来实现。

话虽如此,您的组织看起来很明智。我唯一的改变是将接口与其实现放在一起,而不是放在 Project.Core 中。

Are these projects or namespaces? There's an ancient and ongoing debate about fine-grained verses coarse-grained project structure. I'm in the coarse-grained camp. An assembly is a unit of deployment, not a logical layer, and the structure you are describing is better achieved as namespaces in a single project.

Having said that, your organisation looks sensible. My only change would be to put interfaces alongside their implementations rather than in Project.Core.

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