Questions about event replay

Hi,Axon Team:
I am new to axon,and here there are some questions needed to be answer pls: to replay events against a specified aggregate root rather than all the aggreates? to replay events on a specified aggregate root against a peroid of time?

Thank you in advance!
vilian fung



签名由 网易邮箱大师 定制

I believe events are replayed against an aggregate root automatically when calling .load(aggregateId) on a Repository

Not sure about how to replay events over a time period.

Hi Vilian and Michael,

Michael’s assumption is right, an Aggregate, the Command Model in this case, will be automatically replayed based on the events which constitute all it’s changes.
Under the hood this is due to the usage of the EventSourcingRepository, which is the default repository used for Aggregates.

If you want to replay a given period of time however, you’ll have to set this up yourself.
This is usually not needed for your Command model, as you will execute Commands on a given Aggregate in the Command side of your application, which 9 out of 10 is against the current state of that Aggregate.
From a querying perspective this question makes more sense, as you might want to query a model on a given time stamp.
For that however, you’ll have to create something yourself.

Something along the lines of retrieving the stream of events and handling all the events until a given timestamp occurs, would be the most pragmatic solution I think.
You could also take the stance to store your query model at different points in time, so that you do not have to replay when the question occurs.
All of this depends on the exact use case at hand however.

Hope this helps, do not hesitate to post follow up questions!