I am writing a Java application that connects to a Cassandra database within Microsoft Azure CosmosDB. As per the documentation page at https://learn.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?
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:
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:
You could set the consistency with DataStax driver,referring to this link.