Как установить уровень согласованности в XML-конфигурации Spring Data Cassandra

Я использую Spring-Data-Cassandra 1.2.2. Я использую конфигурацию XML, как показано ниже. Я читал, что ConsistencyLevel по умолчанию равен ONE, я хочу установить его на QUORUM. Как настроить его в XML? При необходимости я могу обновить свою версию Spring-Data-Cassandra.

<?xml version='1.0'?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
 xmlns:context="http://www.springframework.org/schema/context"
 xsi:schemaLocation="http://www.springframework.org/schema/cql http://www.springframework.org/schema/cql/spring-cql.xsd
   http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra.xsd
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

 <!-- Loads the properties into the Spring Context and uses them to fill in placeholders in the bean definitions -->
 <context:property-placeholder location="classpath:resources.properties" />

 <!-- REQUIRED: The Cassandra Cluster -->
 <cassandra:cluster contact-points="${cassandra.contactpoints}" port="${cassandra.port}" />

 <!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace -->
 <cassandra:session keyspace-name="${cassandra.keyspace}" schema-action="CREATE" />

 <!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter -->
 <cassandra:mapping />

 <!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
 <cassandra:converter />

 <!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra -->
 <cassandra:template />

 <!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add your base packages to scan here -->
 <cassandra:repositories base-package="com.my.package.cassandrarepository" />

</beans>

person Harshad Vyawahare    schedule 16.03.2017    source источник
comment
Создайте Cluster самостоятельно. Настройка QueryOptions доступна в CassandraCqlClusterFactoryBean, начиная с Spring Data для Apache Cassandra 1.5, но она недоступна через конфигурацию XML.   -  person mp911de    schedule 16.03.2017
comment
@mp911de - Спасибо за комментарий! Нет ответов на мой вопрос, кажется, JavaConfig - единственное решение. Обновление с 1.2.2 до 1.5 оказалось немного сложным из-за других зависимостей spring-data (mongo & JPA) в моем проекте, поэтому я использовал com.datastax.driver.core.Cluster.builder().withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.QUORUM))   -  person Harshad Vyawahare    schedule 22.03.2017


Ответы (1)


Кажется, JavaConfig - единственное решение. Обновление с 1.2.2 до 1.5 оказалось немного сложным из-за других зависимостей spring-data (mongo & JPA) в моем проекте. Поэтому я использовал следующую конфигурацию в версии 1.2.2: com.datastax.driver.core.Cluster.builder().withQueryOptions(‌​new QueryOptions().setConsistencyLevel(ConsistencyLevel.QUORUM))

person Harshad Vyawahare    schedule 16.01.2018