【发布时间】:2021-07-29 19:40:30
【问题描述】:
我在我的环境中使用以下依赖项:
- spring-boot-starter-parent - v2.3.5.RELEASE
- spring-boot-starter-data-cassandra - 相同
- cassandra-driver-core (com.datastax.cassandra) - v3.2.0
如何在我的设置中访问在com.datastax.driver.core.PoolingOptions 中设置的连接池选项?
Spring Data Cassandra (SDC) 文档指定以下内容:
AbstractCassandraConfiguration 让您提供各种配置 选项,例如初始实体、默认查询选项、池 选项、套接字选项等等。
但我一辈子都找不到在 DS 驱动程序中设置这些池选项的位置:(
似乎 Spring 数据 Cassandra 中的 CassandraClusterFactoryBean 和 PoolingOptionsFactoryBean 已被删除,我不明白如何在没有这些或通过我编写的 AbstractCassandraConfiguration 扩展/实现的情况下获取 PoolingOptions 的句柄。
下面应该是支持的池选项。但是如何访问在代码中保存这些配置的 PoolingOptions bean?
Connection pooling options
cassandra.pool.heartbeat-interval-seconds - heartbeat interval in seconds.
cassandra.pool.idle-timeout-seconds - idle connection timeout in seconds.
cassandra.pool.pool-timeout-millis - timeout for acquiring connection from pool in ms.
cassandra.pool.local.core-connections-per-host - initial number of connections to each "local" host.
cassandra.pool.local.max-connections-per-host - max number of connections to each "local" host.
cassandra.pool.local.max-requests-per-connection - max number of requests per connections to "local" host.
cassandra.pool.local.new-connection-threshold - threshold to trigger new connection to "local" host.
cassandra.pool.remote.core-connections-per-host - initial number of connections to each "remote" host.
cassandra.pool.remote.max-connections-per-host - max number of connections to each "remote" host.
cassandra.pool.remote.max-requests-per-connection - max number of requests per connections to "remote" host.
cassandra.pool.remote.new-connection-threshold - threshold to trigger new connection to "remote" host.
SDC 文档中还提到:
DataStax Java Driver 4 将
Cluster和Session对象合并到一个 单个CqlSession对象,因此,所有与集群相关的 API 都是 删除。
为了反映配置生成器的变化,
ClusterBuilderConfigurer更名为SessionBuilderConfigurer现在接受CqlSessionBuilder而不是Cluster.Builder
感谢任何帮助。
【问题讨论】:
标签: java spring-boot cassandra connection-pooling spring-data-cassandra