ChangeFeedProcessorOptions Class

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

public final class ChangeFeedProcessorOptions

Specifies the options associated with ChangeFeedProcessor.

Field Summary

Modifier and Type Field and Description
static final Duration DEFAULT_ACQUIRE_INTERVAL

Default acquire interval.

static final Duration DEFAULT_EXPIRATION_INTERVAL

Default expiration interval.

static final Duration DEFAULT_FEED_POLL_DELAY

Default feed poll delay.

static final Duration DEFAULT_RENEW_INTERVAL

Default renew interval.

Constructor Summary

Constructor Description
ChangeFeedProcessorOptions()

Instantiates a new Change feed processor options.

Method Summary

Modifier and Type Method and Description
Duration getFeedPollDelay()

Gets the delay in between polling a partition for new changes on the feed, after all current changes are drained.

ThroughputControlGroupConfig getFeedPollThroughputControlGroupConfig()

Get the feed pool throughput control config.

Duration getLeaseAcquireInterval()

Gets the interval to kick off a task to compute if partitions are distributed evenly among known host instances.

Duration getLeaseExpirationInterval()

Gets the interval for which the lease is taken on a lease representing a partition.

String getLeasePrefix()

Gets a prefix to be used as part of the lease ID.

Duration getLeaseRenewInterval()

Gets the renew interval for all leases for partitions currently held by ChangeFeedProcessor instance.

int getMaxItemCount()

Gets the maximum number of items to be returned in the enumeration operation in the Azure Cosmos DB service.

int getMaxScaleCount()

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

int getMinScaleCount()

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

Scheduler getScheduler()

Gets the internal Scheduler that hosts a pool of ExecutorService-based workers for any change feed processor related tasks.

String getStartContinuation()

Gets the start request continuation token to start looking for changes after.

Instant getStartTime()

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

boolean isStartFromBeginning()

Gets a value indicating whether change feed in the Azure Cosmos DB service should start from beginning (true) or from current (false).

ChangeFeedProcessorOptions setFeedPollDelay(Duration feedPollDelay)

Sets the delay in between polling a partition for new changes on the feed, after all current changes are drained.

ChangeFeedProcessorOptions setFeedPollThroughputControlConfig(ThroughputControlGroupConfig feedPollThroughputControlGroupConfig)

Set the feed poll local throughput control config.

ChangeFeedProcessorOptions setLeaseAcquireInterval(Duration leaseAcquireInterval)

Sets he interval to kick off a task to compute if partitions are distributed evenly among known host instances.

ChangeFeedProcessorOptions setLeaseExpirationInterval(Duration leaseExpirationInterval)

Sets the interval for which the lease is taken on a lease representing a partition.

ChangeFeedProcessorOptions setLeasePrefix(String leasePrefix)

Sets a prefix to be used as part of the lease ID.

ChangeFeedProcessorOptions setLeaseRenewInterval(Duration leaseRenewInterval)

Sets the renew interval for all leases for partitions currently held by ChangeFeedProcessor instance.

ChangeFeedProcessorOptions setMaxItemCount(int maxItemCount)

Sets the maximum number of items to be returned in the enumeration operation.

ChangeFeedProcessorOptions setMaxScaleCount(int maxScaleCount)

Sets the maximum number of partitions (parallel workers) the host can run.

ChangeFeedProcessorOptions setMinScaleCount(int minScaleCount)

Sets the minimum partition count (parallel workers) for the current host.

ChangeFeedProcessorOptions setScheduler(Scheduler scheduler)

Sets the internal Scheduler that hosts a pool of ExecutorService-based workers for any change feed processor related tasks.

ChangeFeedProcessorOptions setStartContinuation(String startContinuation)

Sets the start request continuation token to start looking for changes after.

ChangeFeedProcessorOptions setStartFromBeginning(boolean startFromBeginning)

Sets a value indicating whether change feed in the Azure Cosmos DB service should start from beginning.

ChangeFeedProcessorOptions setStartTime(Instant startTime)

Sets the time (exclusive) to start looking for changes after (UTC time).

Methods inherited from java.lang.Object

Field Details

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.

DEFAULT_RENEW_INTERVAL

public static final Duration DEFAULT_RENEW_INTERVAL

Default renew interval.

Constructor Details

ChangeFeedProcessorOptions

public ChangeFeedProcessorOptions()

Instantiates a new Change feed processor options.

Method Details

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.

getFeedPollThroughputControlGroupConfig

public ThroughputControlGroupConfig getFeedPollThroughputControlGroupConfig()

Get the feed pool throughput control config.

Returns:

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.

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.

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.

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.

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.

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.

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.

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..

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.

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.

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.

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.

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:

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Applies to