MongoDB Java driver: autoConnectRetry

ぐ巨炮叔叔 提交于 2019-11-29 09:25:02

问题


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 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?


回答1:


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.

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).

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).



来源:https://stackoverflow.com/questions/23295333/mongodb-java-driver-autoconnectretry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!