0
votes

I am writing a Java application that connects to a Cassandra database within Microsoft Azure CosmosDB. As per the documentation page at https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-manage-consistency, cosmosdb has an option to set the consistency level for a read operation. I am, however, unable to find examples of how to do this while using the SQL API for cassandra. I am extending the example provided by Microsoft at https://github.com/Azure-Samples/azure-cosmos-db-cassandra-java-getting-started. The example uses the datastax driver cassandra.

Is it possible to set the consistency level using this driver?

1
Hi,does my answer helps you?If so ,you could mark it for others' references.ThanksJay Gong

1 Answers

0
votes

Can't find anything about consistency settings in the source code you provided.Actually, the mechanism of Azure Cosmos DB’s Cassandra API consistency level is different from other cosmos db api(such as SQL api,Gremlin api etc.)

Please read the statements in this link.

When using Azure Cosmos DB’s Cassandra API:

  • The write consistency level of Apache Cassandra is mapped to the default consistency level configured on your Azure Cosmos account.
  • Azure Cosmos DB will dynamically map the read consistency level specified by the Cassandra client driver to one of the Azure Cosmos DB consistency levels configured dynamically on a read request.

So, based on my understanding,the consistency of cosmos db doesn't interfere with your driver's original consistency settings, but maps them according to the following table:

enter image description here

You could set the consistency with DataStax driver,referring to this link.