Question about implementing “closing the books” pattern in Axon 5
I have a command handling component named ValidateSupportRequestCommandHandler that needs an event-sourced entity. This entity is populated by the following events:
GiftRegistratedSupportApprovedWaitingSupportApproved
With these events, you can determine the current balance. Based on this balance, either a SupportApproved event, a tuple of (SupportApproved, WaitingSupportApproved), or no events are added to the event store.
The problem is that the number of events that need to be sourced could potentially become huge. I want to implement the “closing the books” principle by introducing an EndOfTheDayBalance event. This way, only the most recent EndOfTheDayBalance and the relevant events that occurred after it need to be sourced.
What is the best way to implement this in Axon 5? More concrete, Is there a way to define an EventCriteriaBuilder that filter events of a specific type occured after a specific event?