condições de parada e retry, utilizar classe perfil.
This commit is contained in:
parent
a170168f21
commit
ddcc46c3d0
@ -178,23 +178,22 @@ internal class Plat_integ
|
||||
}
|
||||
}
|
||||
|
||||
string resposta = await response.Content.ReadAsStringAsync(ct);
|
||||
await ProcessarXMLAsync(resposta, await dataSource.OpenConnectionAsync());
|
||||
await ProcessarXMLAsync(resposta, dataSource, dia, perfil._Cod_5min, perfil._Codigo_SCDE, existentes, limiter, ct, 1);
|
||||
|
||||
sucesso = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tentativas++;
|
||||
if (tentativas == 5)
|
||||
if (tentativas >= 5)
|
||||
{
|
||||
errosPersistentes.Add($"{item.Item1};{item.Item2};Erro;{ex.Message.Replace("\n", "-n-")}");
|
||||
errosPersistentes.Add($"{perfil._Cod_5min};{perfil._Codigo_SCDE};Erro;{ex.Message.Replace("\n", "-n-")}");
|
||||
}
|
||||
else
|
||||
{
|
||||
int backoff = (int)Math.Pow(2.4, tentativas) * 1000; // exponencial
|
||||
Console.WriteLine($"Erro na requisição ({ex.Message}), tentativa {tentativas}. Aguardando {backoff / 1000}s...");
|
||||
await Task.Delay(backoff, ct);
|
||||
await Task.Delay(backoff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user