use of com.azure.cosmos.CosmosAsyncDatabase in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SalesOrder method ManageConflictResolutionPoliciesInAzureCosmosDBSprocAsync.
/**
* 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 ManageConflictResolutionPoliciesInAzureCosmosDBSprocAsync() {
String container_id = "family_container";
String partition_key = "/pk";
CosmosAsyncDatabase database = null;
// <ManageConflictResolutionSprocAsync>
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy("resolver");
CosmosContainerProperties containerProperties = new CosmosContainerProperties(container_id, partition_key);
containerProperties.setConflictResolutionPolicy(policy);
/* ...other container config... */
database.createContainerIfNotExists(containerProperties).block();
// </ManageConflictResolutionSprocAsync>
}
use of com.azure.cosmos.CosmosAsyncDatabase in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SalesOrder method MigrateJavaSDKv4ItemTTLAsync.
/**
* https://docs.microsoft.com/en-us/azure/cosmos-db/migrate-java-v4-sdk
* Item TTL
*/
/**
* Item TTL
*/
public static void MigrateJavaSDKv4ItemTTLAsync() {
String hostName = "hostname";
String partition_key = "/pk";
CosmosAsyncDatabase database = null;
// <MigrateItemTTLAsync>
// Set the value to the expiration in seconds
SalesOrder salesOrder = new SalesOrder("SO05", "CO18009186470", // Expire sales orders in 30 days
60 * 60 * 24 * 30);
// </MigrateItemTTLAsync>
}
Aggregations