DocumentDB TransientFaultHandling for Core

时间:2017-04-06 16:44:48

标签: asp.net-core azure-cosmosdb

I am trying to migrate my code to Core.

I was using DocumentDB TransientFaultHandling package, but I can't seem to find it for a Core library.

Is it still best practice to use it, or are there other options for achieving the same results?

TIA

1 个答案:

答案 0 :(得分:5)

当前的SDK(Core和Full Framework)已经包含了作为TransientFaultHandling软件包一部分的故障处理,并不完全相同,因为您无法定义指数逻辑,但它适用于最常见的方案

它位于ConnectionPolicy设置:

var _dbClient = new DocumentClient("Db_uri", "Db_key", new ConnectionPolicy()
{
    MaxConnectionLimit=100,
    ConnectionMode = ConnectionMode.Direct,
    ConnectionProtocol = Protocol.Tcp,
    RetryOptions = new RetryOptions() { MaxRetryAttemptsOnThrottledRequests=3, MaxRetryWaitTimeInSeconds=60 }
});