Search in sources :

Example 6 with ConflictResolutionPolicy

use of com.azure.cosmos.models.ConflictResolutionPolicy in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class SampleDocumentationSnippets method ManageConflictResolutionPoliciesInAzureCosmosDBSprocSync.

/**
 * https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-manage-conflicts
 * Resolve conflicts, stored procedure
 */
/**
 * Client-side conflict resolution using stored procedure
 */
public static void ManageConflictResolutionPoliciesInAzureCosmosDBSprocSync() {
    String container_id = "family_container";
    String partition_key = "/pk";
    CosmosDatabase database = null;
    // <ManageConflictResolutionSprocSync>
    ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy("resolver");
    CosmosContainerProperties containerProperties = new CosmosContainerProperties(container_id, partition_key);
    containerProperties.setConflictResolutionPolicy(policy);
    /* ...other container config... */
    database.createContainerIfNotExists(containerProperties);
// </ManageConflictResolutionSprocSync>
}
Also used : CosmosDatabase(com.azure.cosmos.CosmosDatabase) CosmosContainerProperties(com.azure.cosmos.models.CosmosContainerProperties) ConflictResolutionPolicy(com.azure.cosmos.models.ConflictResolutionPolicy)

Aggregations

ConflictResolutionPolicy (com.azure.cosmos.models.ConflictResolutionPolicy)6 CosmosContainerProperties (com.azure.cosmos.models.CosmosContainerProperties)6 CosmosAsyncDatabase (com.azure.cosmos.CosmosAsyncDatabase)3 CosmosDatabase (com.azure.cosmos.CosmosDatabase)3