Compartir a través de


ChangeFeedPolicy Class

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

public final class ChangeFeedPolicy

Represents the change feed policy configuration for the container in the Azure Cosmos DB service.

The example below creates a new container with a change feed policy for AllVersionsAndDeletes change feed with a retention window of 8 minutes - so intermediary snapshots of changes as well as deleted documents would be available for processing for 8 minutes before they vanish. Processing the change feed with AllVersionsAndDeletes mode will only be able within this retention window - if you attempt to process a change feed after more than the retention window (8 minutes in this sample) an error (Status Code 400) will be returned. It would still be possible to process changes using LatestVersion mode even when configuring a AllVersionsAndDeletes change feed policy with retention window on the container and when using LatestVersion mode it doesn't matter whether you are out of the retention window or not.

CosmosContainerProperties containerProperties =
      new CosmosContainerProperties("ContainerName", "/somePartitionKeyProperty");
 containerProperties.setChangeFeedPolicy(ChangeFeedPolicy.createAllVersionsAndDeletesPolicy(8));

 CosmosAsyncDatabase database = client.createDatabase(databaseProperties).block().getDatabase();
 CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();

The example below creates a new container with a change feed policy for LatestVersion change feed. Processing the change feed with AllVersionsAndDeletes mode will not be possible for this container. It would still be possible to process changes using LatestVersion mode. The LatestVersion change feed policy is also the default that is used when not explicitly specifying a change feed policy.

CosmosContainerProperties containerProperties =
      new CosmosContainerProperties("ContainerName", "/somePartitionKeyProperty");
 containerProperties.setChangeFeedPolicy(ChangeFeedPolicy.createLatestVersionPolicy());

 CosmosAsyncDatabase database = client.createDatabase(databaseProperties).block().getDatabase();
 CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();

Method Summary

Modifier and Type Method and Description
static ChangeFeedPolicy createAllVersionsAndDeletesPolicy(Duration retentionDuration)

Creates a ChangeFeedPolicy with retention duration for AllVersionsAndDeletes processing

static ChangeFeedPolicy createFullFidelityPolicy(Duration retentionDuration)

Deprecated

Creates a ChangeFeedPolicy with retention duration for AllVersionsAndDeletes processing

static ChangeFeedPolicy createIncrementalPolicy()

Deprecated

Creates a default ChangeFeedPolicy without retention duration specified.

static ChangeFeedPolicy createLatestVersionPolicy()

Creates a default ChangeFeedPolicy without retention duration specified.

Duration getFullFidelityRetentionDuration()

Deprecated

Gets the retention duration in which it will be possible to process change feed events with AllVersionsAndDeletes mode (meaning intermediary changes and deletes will be exposed in change feed).

Duration getRetentionDurationForAllVersionsAndDeletesPolicy()

Gets the retention duration in which it will be possible to process change feed events with AllVersionsAndDeletes mode (meaning intermediary changes and deletes will be exposed in change feed).

Methods inherited from java.lang.Object

Method Details

createAllVersionsAndDeletesPolicy

public static ChangeFeedPolicy createAllVersionsAndDeletesPolicy(Duration retentionDuration)

Creates a ChangeFeedPolicy with retention duration for AllVersionsAndDeletes processing

Parameters:

retentionDuration -
  • the retention duration (max granularity in minutes) in which it will be possible to process change feed events with AllVersionsAndDeletes mode.

Returns:

ChangeFeedPolicy for AllVersionsAndDeletes change feed.

createFullFidelityPolicy

@Deprecated
public static ChangeFeedPolicy createFullFidelityPolicy(Duration retentionDuration)

Deprecated

Creates a ChangeFeedPolicy with retention duration for AllVersionsAndDeletes processing

Parameters:

retentionDuration -
  • the retention duration (max granularity in minutes) in which it will be possible to process change feed events with AllVersionsAndDeletes mode.

Returns:

ChangeFeedPolicy for AllVersionsAndDeletes change feed.

createIncrementalPolicy

@Deprecated
public static ChangeFeedPolicy createIncrementalPolicy()

Deprecated

Creates a default ChangeFeedPolicy without retention duration specified. With the default/LatestVersion change feed it will not be possible to process intermediary changes or deletes.

This is the default policy being used when not specifying any ChangeFeedPolicy for the Container.

Returns:

ChangeFeedPolicy for default/LatestVersion change feed without AllVersionsAndDeletes.

createLatestVersionPolicy

public static ChangeFeedPolicy createLatestVersionPolicy()

Creates a default ChangeFeedPolicy without retention duration specified. With the default/LatestVersion change feed it will not be possible to process intermediary changes or deletes.

This is the default policy being used when not specifying any ChangeFeedPolicy for the Container.

Returns:

ChangeFeedPolicy for default/LatestVersion change feed without AllVersionsAndDeletes.

getFullFidelityRetentionDuration

@Deprecated
public Duration getFullFidelityRetentionDuration()

Deprecated

Gets the retention duration in which it will be possible to process change feed events with AllVersionsAndDeletes mode (meaning intermediary changes and deletes will be exposed in change feed). By default AllVersionsAndDeletes change feed is not enabled - so the retention duration would be Duration.ZERO.

Returns:

AllVersionsAndDeletes retention duration.

getRetentionDurationForAllVersionsAndDeletesPolicy

public Duration getRetentionDurationForAllVersionsAndDeletesPolicy()

Gets the retention duration in which it will be possible to process change feed events with AllVersionsAndDeletes mode (meaning intermediary changes and deletes will be exposed in change feed). By default AllVersionsAndDeletes change feed is not enabled - so the retention duration would be Duration.ZERO.

Returns:

AllVersionsAndDeletes retention duration.

Applies to