MongoDB Java驱动程序:autoConnectRetry [英] MongoDB Java driver: autoConnectRetry

查看:583
本文介绍了MongoDB Java驱动程序:autoConnectRetry的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前的连接配置如下所示:

Our current connection configuration looks like this:

MongoClientOptions.builder()
    .autoConnectRetry(true).maxAutoConnectRetryTime(1200000)
    .socketTimeout(30000).connectTimeout(15000).build();
     // SocketTimeout: 30s, ConnectionTimeout 15s, ReconnectRetry: 20min

autoConnectRetry 和 maxAutoConnectRetryTime 源代码)并将被删除:此方法没有替代品。使用connectTimeout用于控制连接超时的属性。

autoConnectRetry and maxAutoConnectRetryTime are deprecated in the current version (source code) and will be removed: "There is no replacement for this method. Use the connectTimeout property to control connection timeout."

我认为重试和连接超时是两回事。有谁知道为什么这会改变以及它有什么(内部)影响?

I thought retries and connection timeouts were two different things. Does anyone know why this was changed and what (internal) implications this has?

推荐答案

关于意义有很多混淆of autoConnectRetry。大多数人认为这意味着,如果操作因IOException而失败,驱动程序将重试该操作,直到maxAutoConnectRetryTime结束。但事实并非如此。

There was a lot of confusion about the meaning of autoConnectRetry. Most people think it means that, if an operation failed due to an IOException, the driver would retry the operation until maxAutoConnectRetryTime elapsed. But that is not the case.

所有这一切都意味着,在调用Socket.connect()时,驱动程序会重试失败的连接尝试,直到maxAutoConnectRetryTime结束。但这正是connectTimeout的用途。 autoConnectRetry的唯一附加功能是,您可以指定比基础操作系统允许的更长的连接超时(通常会强制实施最大连接超时,限制用户指定的值)。

All it means is that, on calls to Socket.connect(), the driver retries a failed attempt to connect until maxAutoConnectRetryTime elapsed. But this is exactly what connectTimeout is for. The only additional capability of autoConnectRetry is so that you can specify a longer connect timeout than is allowed by the underlying operating system (which typically enforces a max connect timeout that caps the value that the user specifies).

由于这种混淆,该功能缺乏价值,以及没有其他MongoDB驱动程序支持此功能,我们决定弃用它(并在下一个主要版本中将其删除)。

Due to this confusion, the lack of value of the feature, and the fact that none of the other MongoDB drivers support this feature, we decided to deprecate it (and remove it in the next major release).

这篇关于MongoDB Java驱动程序:autoConnectRetry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆