DATACMNS-975 - Make sure repository method is invoked before event publication.
To make sure that event handlers can read the state of the aggregate persisted, we now invoke the call to the repository before publishing the events. That shouldn't make too much of a difference to most listeners as the event usually contains a reference to the aggregate. However, the new model generally aligns with the approach of reporting what *already has happened* better that our previous approach of first publishing the events and then invoking the repository method. Related tickets: DATACMNS-928.
This commit is contained in:
@@ -87,15 +87,17 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
|
||||
Object result = invocation.proceed();
|
||||
|
||||
if (!invocation.getMethod().getName().equals("save")) {
|
||||
return invocation.proceed();
|
||||
return result;
|
||||
}
|
||||
|
||||
for (Object argument : invocation.getArguments()) {
|
||||
eventMethod.publishEventsFrom(argument, publisher);
|
||||
}
|
||||
|
||||
return invocation.proceed();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user