简体   繁体   中英

How can we configure number of retry attempts in MongoDB Java driver?

We are using spring-data-mongodb-2.2.3.RELEASE with Mongo4.0 in our eco system. We need to configure number of retries in case of failed network connections. retryReads() and retryWrites() enable the operations but how many times will they retry?

There is a property to set timeout for which driver will wait and retry and then gives exception. Does this mean it will only retry once?

Retryable reads and writes, as implemented in most drivers, retry exactly once and this is not configurable.

Some drivers like the Ruby driver have legacy retry functionality where the number of retries is configurable. This functionality is deprecated.

in case of failed network connections

There are various mechanisms in the drivers to avoid using dead network connections. For example, if any one connection experiences a network error, all connections are supposed to be discarded and replaced.

Similarly a failure to create a connection should not be immediately propagated to the application - the driver is meant to retry connection creation up to allowed connection pool checkout time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM