gremlin - 关闭 SessionClient 上的连接 - AWS Neptune
问题描述
我使用 aws-neptune。我尝试将我的查询实现为事务性的(使用 sessionClient,例如:https ://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-sessions.html )。但是当我尝试实现它时,关闭客户端会引发异常。有类似我的情况的问题:https ://groups.google.com/g/janusgraph-users/c/N1TPbUU7Szw
我的代码如下所示:
@Bean
public Cluster gremlinCluster()
{
return Cluster.build()
.addContactPoint(GREMLIN_ENDPOINT)
.port(GREMLIN_PORT)
.enableSsl(GREMLIN_SSL_ENABLED)
.keyCertChainFile("classpath:SFSRootCAG2.pem")
.create();
}
private void runInTransaction()
{
String sessionId = UUID.randomUUID().toString();
Client.SessionedClient client = cluster.connect(sessionId);
try
{
client.submit("query...");
}
finally
{
if (client != null)
{
client.close();
}
}
}
例外是:
INFO (ConnectionPool.java:225) - Signalled closing of connection pool on Host{address=...} with core size of 1
WARN (Connection.java:322) - Timeout while trying to close connection on ... - force closing - server will close session on shutdown or expiration.
java.util.concurrent.TimeoutException
at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771)
有什么建议吗?
解决方案
这可能是您在发送查询时无法观察到的服务器连接问题,因为您没有等待未来完成。
当你做 aclient.submit("query...");
时,你会得到一个未来。您需要等待该未来完成以观察任何异常(或成功)。
我建议如下:
- 尝试使用 curl 通过健康状态调用来访问服务器,以验证与服务器的连接。
- 替换为
client.submit("query...");
以client.submit("query...").all().join();
获取与服务器连接期间的错误。
推荐阅读
- rabbitmq - RabbitMQ:在使用 DLX 策略发送到 DLQ 之前向消息头添加异常
- sql - 如何在另一列的基础上写一个where?
- javascript - Openlayers绘制交互:错误:单击后拖放地图
- php - 我的 SQL 需要 40 秒才能运行,但 PHP 会更快地执行相同的操作。这是为什么?
- asp.net - 安全审计问题 [For Asp.Net WebForms]:源代码公开
- angular - 角度项目的 npm 安装不起作用(下载 xmlbuilder 时 ECONNREFUSED)
- php - SQL - 获得准确的逗号分隔
- reactjs - CodeceptJS/Puppeteer 仅在暂停会话期间看到元素
- digital-signature - XpsDocument.SignDigitally 在 IsSignable 上引发 NullReferenceException
- c++ - 这两种符号有什么区别?