We use Axon framework heavily on our event sourced back-end and we are seeing two issues related to replays. Wondering if anyone has a solution for this.
We have a scenario where users import zip files on the root aggregate. Projections of these import events can take a long time to finish depending on the size of the import. So we decided to use an Asynchronous Cluster with 10 executors and SequentialPerAggregatePolicy sequencing policy so long running imports don’t impact other aggregates. This works well on the live system.
We use the beforeReplay() method to set a flag to identify if the system is replaying or live; this flag gets unset in afterReplay() method. This flag is used to skip certain operations we do not want our event handlers to perform when replaying.
However, this is proving to be unreliable as Axon seems to call afterReplay() as soon as it publishes the event on replay without waiting for event handlers to complete; which causes our flag to unset. As a result, event handlers ends up performing those operations we wanted them to skip.
Is there a cleaner way to do this?
Second concern is, on replay there’s the possibility of Axon loading all the events from the event log on a replay. As event handling is lot slower, cluster will inevitably lag and potentially crash when we exceed the memory available. I’ve noticed that you mentioned here (https://groups.google.com/d/msg/axonframework/DCEwZYDfIPg/0PaYrV2ksWEJ) you will be looking at a solution where Axon will throttle replays automatically. Is this out yet?
Appreciate any advice