use of io.spine.server.tenant.AllTenantOperation in project core-java by SpineEventEngine.
the class ProjectionRepository method catchUp.
/**
* Updates projections from the event stream obtained from {@code EventStore}.
*/
public void catchUp() {
setStatus(Status.CATCHING_UP);
final AllTenantOperation op = new AllTenantOperation(boundedContext.getTenantIndex()) {
private final EventStore eventStore = getBoundedContext().getEventBus().getEventStore();
private final Set<EventFilter> eventFilters = getEventFilters();
@Override
public void run() {
// Get the timestamp of the last event. This also ensures we have the storage.
final Timestamp timestamp = nullToDefault(projectionStorage().readLastHandledEventTime());
final EventStreamQuery query = EventStreamQuery.newBuilder().setAfter(timestamp).addAllFilter(eventFilters).build();
eventStore.read(query, new EventStreamObserver(ProjectionRepository.this));
}
};
op.execute();
completeCatchUp();
logCatchUpComplete();
}
Aggregations