Class CatchupSubscriptionModel

java.lang.Object
org.occurrent.subscription.blocking.durable.catchup.CatchupSubscriptionModel
All Implemented Interfaces:
DelegatingSubscriptionModel, Subscribable, SubscriptionModel, SubscriptionModelLifeCycle

public class CatchupSubscriptionModel extends Object implements SubscriptionModel, DelegatingSubscriptionModel
A SubscriptionModel that reads historic cloud events from the all event streams (see EventStoreQueries.all()) until caught up with the PositionAwareSubscriptionModel.globalSubscriptionPosition() of the subscription (you probably want to narrow the historic set events of events by using a Filter when subscribing). It'll automatically switch over to the supplied subscription when all history events are read and the subscription has caught-up.

Note that the implementation uses an in-memory cache (default size is 100 but this can be configured using a CatchupSubscriptionModelConfig) to reduce the number of duplicate event when switching from historic events to the current cloud event position. It's highly recommended that the application logic is idempotent if the cache size doesn't cover all duplicate events.


Also note that the if a the subscription crashes during catch-up mode it'll continue where it left-off on restart, given the no specific `StartAt` position is supplied. For this to work, the subscription must store the subscription position in a SubscriptionPositionStorage implementation periodically. It's possible to configure how often this should happen in the CatchupSubscriptionModelConfig.