Class CatchupSubscriptionModelConfig

java.lang.Object
org.occurrent.subscription.blocking.durable.catchup.CatchupSubscriptionModelConfig

public class CatchupSubscriptionModelConfig extends Object
Configuration for CatchupSubscriptionModel
  • Field Details

    • cacheSize

      public final int cacheSize
    • subscriptionStorageConfig

      public final SubscriptionPositionStorageConfig subscriptionStorageConfig
    • catchupPhaseSortBy

      public final org.occurrent.eventstore.api.SortBy catchupPhaseSortBy
  • Constructor Details

    • CatchupSubscriptionModelConfig

      public CatchupSubscriptionModelConfig(int cacheSize)
      Create a new CatchupSubscriptionModelConfig will the given cache size. Will default to sort by time and then stream version (if time is the same for two events) during the catchup phase. You can change this by calling catchupPhaseSortBy(SortBy).
      Parameters:
      cacheSize - The number of cloud events id's to store in-memory when switching from "catch-up" mode (i.e. querying the EventStoreQueries API) and "subscription" mode (Subscription). The cache is needed to reduce the number of duplicate events the occurs when switching.
    • CatchupSubscriptionModelConfig

      public CatchupSubscriptionModelConfig(SubscriptionPositionStorageConfig subscriptionStorageConfig)
      Create a new CatchupSubscriptionModelConfig will the given subscription storage config. Will default to sort by time and then stream version (if time is the same for two events) during the catchup phase. You can change this by calling catchupPhaseSortBy(SortBy).
      Parameters:
      subscriptionStorageConfig - Configures if and how subscription position persistence should be handled during the catch-up phase.
    • CatchupSubscriptionModelConfig

      public CatchupSubscriptionModelConfig(int cacheSize, SubscriptionPositionStorageConfig subscriptionStorageConfig)
      Create a new CatchupSubscriptionModelConfig will the given settings. Will default to sort by time and then stream version (if time is the same for two events) during the catchup phase. You can change this by calling catchupPhaseSortBy(SortBy).
      Parameters:
      cacheSize - The number of cloud events id's to store in-memory when switching from "catch-up" mode (i.e. querying the EventStoreQueries API) and "subscription" mode (Subscription). The cache is needed to reduce the number of duplicate events the occurs when switching.
      subscriptionStorageConfig - Configures if and how subscription position persistence should be handled during the catch-up phase.
  • Method Details

    • catchupPhaseSortBy

      public CatchupSubscriptionModelConfig catchupPhaseSortBy(org.occurrent.eventstore.api.SortBy sortBy)
      Specify how to sort the events that are read from the event store during catch-up phase. By default, "natural order" is used when no filter is specified, and time then stream version, if time is the same for two events. If you know that you're reading from a datastore that has insertion order support, or if you need a different sort events after they've been filtered by the CatchupSubscriptionModel, you can specify your own sortBy instance here. Note that you most likely need the sortBy instance be covered by an index for it to work efficiently.

      For example, in MongoDB, if you only sort by "time", then if two events have the exact same time, then the order returned from MongoDB is unspecified. Thus the default value of sortBy is SortBy.ascending(TIME, STREAM_VERSION). However, say that your filter is Filter.type(""), then you could create an index, {type : 1, time : 1, _id : 1}, and call catchupPhaseSortBy(SortBy) with SortBy.ascending(TIME, "_id"). This means that MongoDB can efficiently both search for the correct type and then perform a sort based on time, but use "insertion order" if time is the same for two or more events. If you don't supply a filter, then you can instead create the index {time : 1, _id : 1}.

      Parameters:
      sortBy - The SortBy instance to use during catchup phase. Default is SortBy.ascending(TIME, STREAM_VERSION).
      Returns:
      A new instance of CatchupSubscriptionModel.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object