ddd-by-examples / library

A comprehensive Domain-Driven Design example with problem space strategic analysis and various tactical patterns.
MIT License
4.92k stars 727 forks source link

Create concept of PublishedEvent #5

Open pilloPl opened 5 years ago

pilloPl commented 5 years ago

So currently the all of the domain events have information about business facts.

If we want to publish them we need to add metadata like:

causationID, corellationID, uniqueMessageID etc

so PublishedEvent becomes DomainEvent + metadata

ghost commented 5 years ago

So, if I understand correctly, do you mean that

public interface EventsStorage {

    void save(DomainEvent event);

    List<DomainEvent> toPublish();

    void published(List<DomainEvent> events);
}

should be more like

public interface EventsStorage {

    void save(DomainEvent event);

    List<DomainEvent> toPublish();

    void published(List<PublishedEvent> events);
}
pilloPl commented 5 years ago

I mean that PublishedEvent should keep DomainEvent inside :)