Class ChangeFeedProcessorOptions

java.lang.Object
com.azure.cosmos.models.ChangeFeedProcessorOptions

public final class ChangeFeedProcessorOptions extends Object
Specifies the options associated with ChangeFeedProcessor.
  • Field Details

    • DEFAULT_RENEW_INTERVAL

      public static final Duration DEFAULT_RENEW_INTERVAL
      Default renew interval.
    • DEFAULT_ACQUIRE_INTERVAL

      public static final Duration DEFAULT_ACQUIRE_INTERVAL
      Default acquire interval.
    • DEFAULT_EXPIRATION_INTERVAL

      public static final Duration DEFAULT_EXPIRATION_INTERVAL
      Default expiration interval.
    • DEFAULT_FEED_POLL_DELAY

      public static final Duration DEFAULT_FEED_POLL_DELAY
      Default feed poll delay.
  • Constructor Details

    • ChangeFeedProcessorOptions

      public ChangeFeedProcessorOptions()
      Instantiates a new Change feed processor options.
  • Method Details

    • getLeaseRenewInterval

      public Duration getLeaseRenewInterval()
      Gets the renew interval for all leases for partitions currently held by ChangeFeedProcessor instance.
      Returns:
      the renew interval for all leases for partitions.
    • setLeaseRenewInterval

      public ChangeFeedProcessorOptions setLeaseRenewInterval(Duration leaseRenewInterval)
      Sets the renew interval for all leases for partitions currently held by ChangeFeedProcessor instance.
      Parameters:
      leaseRenewInterval - the renew interval for all leases for partitions currently held by ChangeFeedProcessor instance.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getLeaseAcquireInterval

      public Duration getLeaseAcquireInterval()
      Gets the interval to kick off a task to compute if partitions are distributed evenly among known host instances.
      Returns:
      the interval to kick off a task to compute if partitions are distributed evenly among known host instances.
    • setLeaseAcquireInterval

      public ChangeFeedProcessorOptions setLeaseAcquireInterval(Duration leaseAcquireInterval)
      Sets he interval to kick off a task to compute if partitions are distributed evenly among known host instances.
      Parameters:
      leaseAcquireInterval - he interval to kick off a task to compute if partitions are distributed evenly among known host instances.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getLeaseExpirationInterval

      public Duration getLeaseExpirationInterval()
      Gets the interval for which the lease is taken on a lease representing a partition.

      If the lease is not renewed within this interval, it will cause it to expire and ownership of the partition will move to another ChangeFeedProcessor instance.

      Returns:
      the interval for which the lease is taken on a lease representing a partition.
    • setLeaseExpirationInterval

      public ChangeFeedProcessorOptions setLeaseExpirationInterval(Duration leaseExpirationInterval)
      Sets the interval for which the lease is taken on a lease representing a partition.

      If the lease is not renewed within this interval, it will cause it to expire and ownership of the partition will move to another ChangeFeedProcessor instance.

      Parameters:
      leaseExpirationInterval - the interval for which the lease is taken on a lease representing a partition.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getFeedPollDelay

      public Duration getFeedPollDelay()
      Gets the delay in between polling a partition for new changes on the feed, after all current changes are drained.
      Returns:
      the delay in between polling a partition for new changes on the feed.
    • setFeedPollDelay

      public ChangeFeedProcessorOptions setFeedPollDelay(Duration feedPollDelay)
      Sets the delay in between polling a partition for new changes on the feed, after all current changes are drained.
      Parameters:
      feedPollDelay - the delay in between polling a partition for new changes on the feed, after all current changes are drained.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getLeasePrefix

      public String getLeasePrefix()
      Gets a prefix to be used as part of the lease ID.

      This can be used to support multiple instances of ChangeFeedProcessor instances pointing at the same feed while using the same auxiliary container.

      Returns:
      a prefix to be used as part of the lease ID.
    • setLeasePrefix

      public ChangeFeedProcessorOptions setLeasePrefix(String leasePrefix)
      Sets a prefix to be used as part of the lease ID.
      Parameters:
      leasePrefix - a prefix to be used as part of the lease ID.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getMaxItemCount

      public int getMaxItemCount()
      Gets the maximum number of items to be returned in the enumeration operation in the Azure Cosmos DB service.
      Returns:
      the maximum number of items to be returned in the enumeration operation in the Azure Cosmos DB service.
    • setMaxItemCount

      public ChangeFeedProcessorOptions setMaxItemCount(int maxItemCount)
      Sets the maximum number of items to be returned in the enumeration operation.

      NOTE: There are some cases where the number of items returned from the Change Feed can be higher than the specified value. If items in the container are being written through stored procedures, transactional batch, or bulk, they share the same transaction and the same bookkeeping, so they will be returned together when read through the Change Feed.

      Parameters:
      maxItemCount - the maximum number of items to be returned in the enumeration operation.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getStartContinuation

      public String getStartContinuation()
      Gets the start request continuation token to start looking for changes after.

      This option can be used when lease store is not initialized and it is ignored if a lease item exists and has continuation token that is not null. If this is specified, both StartTime and StartFromBeginning are ignored.

      Returns:
      the string representing a continuation token that will be used to get item feeds starting with.
    • setStartContinuation

      public ChangeFeedProcessorOptions setStartContinuation(String startContinuation)
      Sets the start request continuation token to start looking for changes after.

      This option can be used when lease store is not initialized and it is ignored if a lease item exists and has continuation token that is not null. If this is specified, both StartTime and StartFromBeginning are ignored.

      Parameters:
      startContinuation - the start request continuation token to start looking for changes after.
      Returns:
      the string representing a continuation token that will be used to get item feeds starting with.
    • getStartTime

      public Instant getStartTime()
      Gets the time (exclusive) to start looking for changes after.

      This option can be used when: (1) Lease items are not initialized; this setting will be ignored if the lease items exists and have a valid continuation token. (2) Start continuation token option is not specified. If this option is specified, "start from beginning" option is ignored.

      Returns:
      the time (exclusive) to start looking for changes after.
    • setStartTime

      public ChangeFeedProcessorOptions setStartTime(Instant startTime)
      Sets the time (exclusive) to start looking for changes after (UTC time).

      This option can be used when: (1) Lease items are not initialized; this setting will be ignored if the lease items exists and have a valid continuation token. (2) Start continuation token option is not specified. If this option is specified, "start from beginning" option is ignored.

      Parameters:
      startTime - the time (exclusive) to start looking for changes after.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • isStartFromBeginning

      public boolean isStartFromBeginning()
      Gets a value indicating whether change feed in the Azure Cosmos DB service should start from beginning (true) or from current (false). By default it's start from current (false).

      This option can be used when: (1) Lease items are not initialized; this setting will be ignored if the lease items exists and have a valid continuation token. (2) Start continuation token option is not specified. (3) Start time option is not specified.

      Returns:
      a value indicating whether change feed in the Azure Cosmos DB service should start from.
    • setStartFromBeginning

      public ChangeFeedProcessorOptions setStartFromBeginning(boolean startFromBeginning)
      Sets a value indicating whether change feed in the Azure Cosmos DB service should start from beginning.

      This option can be used when: (1) Lease items are not initialized; this setting will be ignored if the lease items exists and have a valid continuation token. (2) Start continuation token option is not specified. (3) Start time option is not specified.

      Parameters:
      startFromBeginning - Indicates to start from beginning if true
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getMinScaleCount

      public int getMinScaleCount()
      Gets the minimum partition count (parallel workers) for the current host.

      This option can be used to increase the number of partitions (parallel workers) for the host and thus override the default equal distribution of leases between multiple hosts.

      Returns:
      the minimum scale count for the host.
    • setMinScaleCount

      public ChangeFeedProcessorOptions setMinScaleCount(int minScaleCount)
      Sets the minimum partition count (parallel workers) for the current host.

      This option can be used to increase the number of partitions (parallel workers) for the host and thus override the default equal distribution of leases between multiple hosts.

      Parameters:
      minScaleCount - the minimum partition count for the host.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getMaxScaleCount

      public int getMaxScaleCount()
      Gets the maximum number of partitions (parallel workers) the host can run.

      This option can be used to limit the number of partitions (parallel workers) for the host and thus override the default equal distribution of leases between multiple hosts. Default setting is "0", unlimited.

      Returns:
      the maximum number of partitions (parallel workers) the host can run.
    • setMaxScaleCount

      public ChangeFeedProcessorOptions setMaxScaleCount(int maxScaleCount)
      Sets the maximum number of partitions (parallel workers) the host can run.

      This option can be used to limit the number of partitions (parallel workers) for the host and thus override the default equal distribution of leases between multiple hosts. Default setting is "0", unlimited.

      Parameters:
      maxScaleCount - the maximum number of partitions (parallel workers) the host can run.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • getScheduler

      public Scheduler getScheduler()
      Gets the internal Scheduler that hosts a pool of ExecutorService-based workers for any change feed processor related tasks.
      Returns:
      a Scheduler that hosts a pool of ExecutorService-based workers..
    • setScheduler

      public ChangeFeedProcessorOptions setScheduler(Scheduler scheduler)
      Sets the internal Scheduler that hosts a pool of ExecutorService-based workers for any change feed processor related tasks.
      Parameters:
      scheduler - a Scheduler that hosts a pool of ExecutorService-based workers. ChangeFeedProcessor instance.
      Returns:
      the current ChangeFeedProcessorOptions instance.
    • setFeedPollThroughputControlConfig

      public ChangeFeedProcessorOptions setFeedPollThroughputControlConfig(ThroughputControlGroupConfig feedPollThroughputControlGroupConfig)
      Set the feed poll local throughput control config. Please use this config with caution. By default, CFP will try to process the changes as fast as possible, only use this config if you want to limit the RU that can be used for your change feed processing. By using this config, it can slow down the process and cause the lag. For direct mode, please configure the throughput control group with the total RU you would allow for changeFeed processing. For gateway mode, please configure the throughput control group with the total RU you would allow for changeFeed processing / total CFP Instances.
      Parameters:
      feedPollThroughputControlGroupConfig - the throughput control for change feed requests for the monitored collection
      Returns:
      the ChangeFeedProcessorOptions.
    • getFeedPollThroughputControlGroupConfig

      public ThroughputControlGroupConfig getFeedPollThroughputControlGroupConfig()
      Get the feed pool throughput control config.
      Returns:
      the ThroughputControlGroupConfig.