Publishing Events from the Domain Model

Domain Events should be published when the fact they represent occurs. For instance, when a new user has been registered, a new UserRegistered Event should be published.

Following the newspaper metaphor:

  • Modeling a Domain Event is like writing a news article
  • Publishing a Domain Event is like printing the article in the paper
  • Spreading a Domain Event is like delivering the newspaper so everyone can read the article

The recommended approach for publishing Domain Events is to use a simple Listener-Observer pattern to implement a DomainEventPublisher.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset