You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One important element of Domain-Driven Design is exposing events important to the domain to other components. These events are produced by aggregates and usually are tied to state transitions of the aggregate. Right now, a typical pattern to produce those events is this:
As you can see, the client needs to use ApplicationEventPublisher explicitly. If we provided a way for the aggregate root to expose the events to be published, the repository could take over the burden to publish the events.
Proposed solution
First of all we need means to let the aggregate root expose the events to be published. This could be an annotation based approach like this:
The annotation name to be open for discussion, of course. We could support to return a Collection of events or a single one. The same could be achieved with an interface, of course.
The repository infrastructure could then inspect the aggregate root type for a method declaration with said annotation (or a type check for the interface pendant) and add an interceptor to the repository proxy that holds a reference to the ApplicationEventPublisher, grabs the events to publish from the aggregate and publishes them before forwarding the call
Oliver Drotbohm opened DATACMNS-928 and commented
Context
One important element of Domain-Driven Design is exposing events important to the domain to other components. These events are produced by aggregates and usually are tied to state transitions of the aggregate. Right now, a typical pattern to produce those events is this:
Problem
As you can see, the client needs to use
ApplicationEventPublisher
explicitly. If we provided a way for the aggregate root to expose the events to be published, the repository could take over the burden to publish the events.Proposed solution
First of all we need means to let the aggregate root expose the events to be published. This could be an annotation based approach like this:
The annotation name to be open for discussion, of course. We could support to return a
Collection
of events or a single one. The same could be achieved with an interface, of course.The repository infrastructure could then inspect the aggregate root type for a method declaration with said annotation (or a type check for the interface pendant) and add an interceptor to the repository proxy that holds a reference to the
ApplicationEventPublisher
, grabs the events to publish from the aggregate and publishes them before forwarding the callReferenced from: commits a02174f, 0fc9770, 9ada55b, 2c0941b, cb6d2f7, c66cbb9, bdf4738, 6927c29, db17a28, afe95b4, 8062698, f6db714, 50ea2ca, c6f9c40, c52c457, 802eb7d, 4177fb4
Backported to: 1.13 RC1 (Ingalls)
2 votes, 5 watchers
The text was updated successfully, but these errors were encountered: