Connect to AWS keyspaces with Spring reactive data autoconfiguration(使用Spring Reactive Data自动配置连接到AWS Keyspace)
问题描述
我正在尝试使用spring-boot-starter-data-cassandra-reactive
连接到我的AWS密钥空间,但收到以下错误:
Error creating bean with name 'cassandraSession' defined in class path resource [com/pams/framework/windsoncore/configurations/CassandraConfiguration.class]: Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=cassandra.us-east-2.amazonaws.com:9142, hostId=null, hashCode=33a6c4f3): [com.datastax.oss.driver.api.core.DriverTimeoutException: [s5|control|id: 0xe0ebe047, L:/10.0.0.128:54474 - R:cassandra.us-east-2.amazonaws.com/3.12.23.155:9142] Protocol initialization request, step 1 (OPTIONS): timed out after 500 ms]
我尝试了他们的文档,很管用,但我想使用Spring自动配置和反应式Cassandra Repos。我在appation.yml中添加了所有配置,并将trustStore
信息作为JVM参数传递。但我无法忘记这些错误。我试着四处寻找这个问题,但没有找到有效的解决方案。
如果有人能帮我一下,我将不胜感激。
我还尝试了以下方法:
@Configuration
@Slf4j
@EnableReactiveCassandraRepositories
public class CassandraConfiguration extends AbstractReactiveCassandraConfiguration {
@Override
protected String getContactPoints() {
return "cassandra.us-east-2.amazonaws.com";
}
@Override
protected int getPort() {
return 9142;
}
@Override
protected String getKeyspaceName() {
return "windson";
}
@Override
protected CqlSession getRequiredSession() {
// TODO Auto-generated method stub
DriverConfigLoader loader = DriverConfigLoader.fromClasspath("application.conf");
return CqlSession.builder().withConfigLoader(loader).build();
}
}
推荐答案
您需要将application.conf
文件中的连接超时时间增加到:
datastax-java-driver {
advanced.connection {
connect-timeout = 5 seconds
init-query-timeout = 5 seconds
}
}
或升级到Java驱动程序4.9,其中init-query-timeout
已从500毫秒增加到5秒。
这篇关于使用Spring Reactive Data自动配置连接到AWS Keyspace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用Spring Reactive Data自动配置连接到AWS Keyspace


基础教程推荐
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01