使用 Spring 反应式数据自动配置连接到 AWS 密钥空间
Connect to AWS keyspaces with Spring reactive data autoconfiguration
我正在尝试使用 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 存储库。我在 application.yml 中添加了所有配置,并将 trustStore
信息作为 JVM args 传递。但我无法克服这些错误。我已经尝试四处寻找,但没有找到可行的解决方案。
如果有人能帮助我,我将不胜感激。
我也试过以下方法:
@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-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 存储库。我在 application.yml 中添加了所有配置,并将 trustStore
信息作为 JVM args 传递。但我无法克服这些错误。我已经尝试四处寻找,但没有找到可行的解决方案。
如果有人能帮助我,我将不胜感激。
我也试过以下方法:
@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 秒。