October 2018
Intermediate to advanced
590 pages
15h 5m
English
We build domain events based on Spring's ApplicationEvent. This allows us to publish and listen to domain events easily. Here is how the DomainEvent class looks:
...public abstract class DomainEvent extends ApplicationEvent { public DomainEvent(Object source) { super(source); } public long occurredAt() { // Return the underlying implementation's timestamp return getTimestamp(); }}
As you can see, it extends from ApplicationEvent and provides its own API, the occurredAt() method, so that we don't rely too much on ApplicationEvent to get the time the event occurred.
The following is how the DomainEventPublisher interface looks:
public interface DomainEventPublisher { void publish(DomainEvent event);}
As you can see, it has ...
Read now
Unlock full access