johanhaleby / occurrent

Unintrusive Event Sourcing Library for the JVM
https://occurrent.org
120 stars 16 forks source link

Improve hand over for CatchupSubscription #163

Closed johanhaleby closed 4 months ago

johanhaleby commented 4 months ago

If all subscriptions would support Timebased subscription position, then we wouldn't need a cache (or just a very small cache). Instead, we would use the latest time-based subscription when we start the wrapped subscription. This should be possible in MongoDB by resuming from a BsonTimestamp in MongoCommons#applyStartPosition. I.e. if we parse the TimeBasedSubscriptionPosition into epoch ms. Note that this can be a bit dangerous outside the context of CatchupSubscirption because starting at a time-based position that is not in the oplog will yield an error (not enough oplog history, but is already handled in eg. SpringSubscriptionModels).