Tag: domain events

为多个订户提升域事件

我正在讨论域事件模式并阅读了很多有关该主题的资源,但我找不到实现我们要求的好方法。 基本上我们有一个服务/域层,它使用简单的CQRS实现包装存储层以进行读/写。 我们有一个ASP.NET Mvc应用程序,它使用这个服务/域层。 整个应用程序与Autofac捆绑在一起,我想要发生的是以下内容: 通过在服务层寄存器上调用“CreateNews”来创建新闻项时,需要引发一个事件: public void CreateNews(Domain.Entities.News.NewsBO news) { ValidateBusinessObject(news); var entityNews = AutoMapper.Mapper.Map(news); NewsCommandRepository.Create(entityNews); _domainEventManager.Register(x => x.News = news); } 这一切都发生在事务中,我不想在保存完成之前实际引发事件,所以在我们的保存更改方法中我想这样做: public void SaveChanges() { _repoCommandManager.SaveChanges(); _domainEventManager.RaiseEvents(); } 然后在我们的ASP.NET Mvc应用程序中,我希望有一个IHandler的实现,如下所示: public class NewsCreatedDomainEventCacheHandler : IHandles { public void Handle(Services.Domain.Events.News.NewsCreatedDomainEvent @event) { // In here we would update the cache or something else […]