domain-events

Is it possible to implement MediatR in the Aggregates (Domain Layer) without dependency injection (DDD)?

不羁岁月 提交于 2020-01-02 10:23:18
问题 To prevent reinventing the wheel, I'd like to use MediatR in the Aggregates to publish domain events. (Un)Fortunately(?) MediatR works as a dependency that is injected into the classes, and not something that I can call statically. Therefore I'd end up creating a direct dependency on the library via the constructor. I don't remember where I read it (and if I read it right), that I should avoid non-business dependencies in the constructors of the Aggregates. Therefore, I shouldn't do something

Is it possible to implement MediatR in the Aggregates (Domain Layer) without dependency injection (DDD)?

给你一囗甜甜゛ 提交于 2020-01-02 10:22:19
问题 To prevent reinventing the wheel, I'd like to use MediatR in the Aggregates to publish domain events. (Un)Fortunately(?) MediatR works as a dependency that is injected into the classes, and not something that I can call statically. Therefore I'd end up creating a direct dependency on the library via the constructor. I don't remember where I read it (and if I read it right), that I should avoid non-business dependencies in the constructors of the Aggregates. Therefore, I shouldn't do something

Integrating DI container within domain layer. Domain events

情到浓时终转凉″ 提交于 2019-12-25 01:49:13
问题 Following the article: http://www.udidahan.com/2009/06/14/domain-events-salvation/ we can see that DomainEvents implemantation uses DI container public static IContainer Container { get; set; } and then if(Container != null) { foreach(var handler in Container.ResolveAll<Handles<T>>()) handler.Handle(args); } Should I integrate DI container inside the same assembly I store domain objects or can I externalize/abstract away the Container.ResolveAll<Handles<T>>() ? (In my previous experiences I

Looking for examples of Domain Events

ε祈祈猫儿з 提交于 2019-12-20 12:36:09
问题 Does any one know where to find example code for an implementation of Domain Events as described by Udi Dahan in Domain Events – Salvation? 回答1: DDDSample.Net has one. 回答2: A better implementation of Domain Events, in my opinion, can be found at https://github.com/bsommardahl/BlingBag. There's a sample application and implementation instructions. I like this implementation more because it doesn't use the static class to raise domain events and doesn't couple your domain to your infrastructure

Can it register an domain event in the constructor of aggregate root, when using Spring Data Common

大憨熊 提交于 2019-12-13 03:15:46
问题 The aggregate will be created by some application service , not by another aggregate. Like this SomeAggregate aggregate = new SomeAggregate(); repo.save(aggregate); The expectation is that the aggregate is saved and one SomeAggregateCreated event is published when the application service is over. I have tested it, it is not always effective, sometimes the event is not registered immediately after the constructor is executed. This is the teacher class: public class Teacher extends

Should the rule “one transaction per aggregate” be taken into consideration when modeling the domain?

*爱你&永不变心* 提交于 2019-12-12 08:14:54
问题 Taking into consideration the domain events pattern and this post , why do people recomend keeping one aggregate per transaction model ? There are good cases when one aggregate could change the state of another one . Even by removing an aggregate (or altering it's identity) will lead to altering the state of other aggregates that reference it. Some people say that keeping one transaction per aggregates help scalability (keeping one aggregate per server) . But doesn't this type of thinking

Who is responsible for entity's mutation when domain event is raised? DDD

和自甴很熟 提交于 2019-12-09 03:18:43
问题 I've been learning about CQRS / ES . Looking at small example projects I often see events mutating the entity state . For instance If we look at the Order aggregate root : public class Order : AggregateRoot { private void Apply(OrderLineAddedEvent @event) { var existingLine = this.OrderLines.FirstOrDefault( i => i.ProductId == @event.ProductId); if(existingLine != null) { existingLine.AddToQuantity(@event.Quantity); return; } this.OrderLines.Add(new OrderLine(@event.ProductId, @event

Entity persitance inside Domain Events using a repository and Entity Framework?

醉酒当歌 提交于 2019-12-08 01:57:33
问题 I am delving into domain events and need some advice about persisting updates to an entity for history reasons. My example deals with a User entity and Signing In: public class UserService { private UserRepository _repository; public UserService() { _repository = new UserRepository(); } public User SignIn(string username, string password) { var user = _repository.FindByUsernameAndPassword(username, password); //As long as the found object is valid and an exception has not been thrown we can

Entity persitance inside Domain Events using a repository and Entity Framework?

ぃ、小莉子 提交于 2019-12-06 04:41:37
I am delving into domain events and need some advice about persisting updates to an entity for history reasons. My example deals with a User entity and Signing In: public class UserService { private UserRepository _repository; public UserService() { _repository = new UserRepository(); } public User SignIn(string username, string password) { var user = _repository.FindByUsernameAndPassword(username, password); //As long as the found object is valid and an exception has not been thrown we can raise the event. user.LastLoginDate = DateTime.Now; user.SignIn(); return user; } } public class User {

Raising Domain Events For Multiple Subscribers

守給你的承諾、 提交于 2019-12-04 15:48:18
问题 I am stating to look into the Domain Events pattern and have read a lot of resources on the subject but I cannot find a good way of implementing for our requirements. Basically we have a Service/Domain layer which wraps the repository layer for reads/writes with a simplistic CQRS implementation. We have an ASP.NET Mvc application which consumes this service/domain layer. The whole application is tied together with Autofac and what I would like to happen is for the following: When a news item