Search in sources :

Example 1 with AllTenantOperation

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();
}
Also used : EventStore(io.spine.server.event.EventStore) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) EventStreamQuery(io.spine.server.event.EventStreamQuery) Timestamp(com.google.protobuf.Timestamp) AllTenantOperation(io.spine.server.tenant.AllTenantOperation)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 Timestamp (com.google.protobuf.Timestamp)1 EventStore (io.spine.server.event.EventStore)1 EventStreamQuery (io.spine.server.event.EventStreamQuery)1 AllTenantOperation (io.spine.server.tenant.AllTenantOperation)1 Set (java.util.Set)1