Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring-data-cassandra set consistency level

I am using spring-data-cassandra (1.3.1.RELEASE) to connect to a cassandra database. Is there a way to change the consistency level in spring-data-cassandra. By default it is level 1 (What is the default consistency level in spring-data-cassandra?). But how to change that?

Thank you!

like image 377
K.E. Avatar asked Nov 25 '15 16:11

K.E.


2 Answers

You can now set this level in spring boot by setting the following properties in application.properties file.

spring.data.cassandra.consistency-level=quorum
spring.data.cassandra.serial-consistency-level=quorum
like image 100
Hasson Avatar answered Sep 21 '22 16:09

Hasson


It is not possible to set a custom consistency level when using the CrudRepository Interface of spring-data-cassandra. There is an open issue https://jira.spring.io/browse/DATACASS-14. Reason is that the SimpleCassandraRepository which implements the methods of the interface calls the CassandraOperations methods without the WriteOptions parameter.

My solution: I wrote a custom crudrepository implementation, in this I can set the consistency level on my own.

like image 31
K.E. Avatar answered Sep 22 '22 16:09

K.E.