Hi,
I need to know which is the best place to create Domain Events and Raise it. Is it better to keep it inside Domain or move it Service level.
If i keep it at domain level then domain needs to access infrastructure services to send events, here domain has the knowledge of infrastructure. If i move to service layer, then i am shifting the responsibility to service layer.
Can you tell me which is the best way approach and why?
-Manjunath
Hi, the aggregate roots raise the domain events.
Domain events are raised as a consequence of commands, for instance if you have a ShipContainer Command, your Cargo aggregate root will raise a ContainerShipped Event, indicating to the rest of the system that a change actually occured.
At the infrastructure problem, Event (or message bus) Framework Ignorance should be done quite as Persistance ignorance : the aggregate root will raise a standard .Net event, but when hydrating the entity, the repository will subscribe the event. When the event is raised by the entity, the repository will forward it to the domain event infrastructure.
If you go through the whole Event Sourcing path, the repository will store the events to the Event Storage in a transaction with the publication of events.
Hope it helps.
Ah, What? I'm sorry. To me this is one of the most confusing aspects of DDD. So basically, you would have the namespace Domain.Events... right?
In there, you would have all of your event objects because event objects do not belong in the Model/Module package, is that right?
Sorry, I'm new here. If you have code samples, please share them.
Moving on
You're saying that the aggregate root raises the event. A standard .NET event, not a Domain Event??? The repository will subscribe to that event?
Instead of me rambling on, could you please break it down in greater detail?
Some good code around this can be fond at Mark's blog and his CQRS sample code:
http://blog.fohjin.com/blog/2009/11/3/CQRS_a_la_Greg_Young_example_code
Thanks Jak - great source code and a good blog to add to the ole rss feeder.
St Louis Hotels | St Louis Attractions | St Louis Missouri