本文介紹了使用Spring Reactive Data自動(dòng)配置連接到AWS Keyspace的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我正在嘗試使用spring-boot-starter-data-cassandra-reactive
連接到我的AWS密鑰空間,但收到以下錯(cuò)誤:
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自動(dòng)配置和反應(yīng)式Cassandra Repos。我在appation.yml中添加了所有配置,并將trustStore
信息作為JVM參數(shù)傳遞。但我無(wú)法忘記這些錯(cuò)誤。我試著四處尋找這個(gè)問(wèn)題,但沒(méi)有找到有效的解決方案。
如果有人能幫我一下,我將不勝感激。
我還嘗試了以下方法:
@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
文件中的連接超時(shí)時(shí)間增加到:
datastax-java-driver {
advanced.connection {
connect-timeout = 5 seconds
init-query-timeout = 5 seconds
}
}
或升級(jí)到Java驅(qū)動(dòng)程序4.9,其中init-query-timeout
已從500毫秒增加到5秒。
這篇關(guān)于使用Spring Reactive Data自動(dòng)配置連接到AWS Keyspace的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,