Hi,
This is what I was thinking about (warning: pseudo code):
@EventHandler
void on(SomeEvent event) {
UnitOfWork<?> uow = CurrentUnitWork.get();
uow.getOrComputeResource(this.toString(), s -> {
uow.afterCommit(u -> updateClient());
return new Object();
})
}
Looking at the above code sample there seems to be a lot of room for improvement :). One option that is being considered is to add an event handler parameter that lets you know if an event was at the end of a batch, e.g.:
@EventHandler
void on(SomeEvent event, @LastInBatch boolean lastInBatch) {
if (lastInBatch) {
updateClient();
}
}
This will probably make it in the Axon 3.0 final release (but no promises :p).
Regards,
Rene