point in time reconstruction

Hi,

A common usecase in the application we’re developing is being able to reconstruct the state of an object (the AR) at a given point in time indicated by a specific marker event in the event stream. At first i thought that this is where the replay functionality comes into play, but replay has a number of side effects which make me think that it was not intended for this use case. Besides the doc state that replay should be considered as a maintenance operation.

This post here https://groups.google.com/d/msg/axonframework/ANlf0chAEYo/LmOdmd7ijCIJ indicates that an EventVisitor is probably what i should use, but it is not referenced in the documentation and i cannot find anything really useful here. From the axon sources itself i get the impression that it’s more a lower-level internal interface. Has anyone figured out how to actually use it, where to plug it etc ?

Thanks,
Jorg

For posterity: i was able to do what i need like this

`

// read the events from the beginning up until the required version
DomainEventStream stream = eventStore.readEvents(MyAR.class.getSimpleName(), id, 0, version);
EventBus eventBus = new SimpleEventBus();
// this projection reconstructs the view model, has annotated @EventHandler methods
HistoricalProjection p = new HistoricalProjection();
eventBus.subscribe(new AnnotationEventListenerAdapter§);
while (stream.hasNext()) {
DomainEventMessage eventMessage = stream.next();
eventBus.publish(eventMessage);
}
// obtain the reconstructed view
p.get();

`

All in all very simple, just had to figure it out :slight_smile:

Jorg

Hi Jorg,

glad you found it.
A little note about the code: you don’t need to instantiate an Event Bus here. You can publish straight to the AnnotationEventListenerAdapter instead. Nothing special, just helps you to get rid of a component.

Cheers,

Allard