我正在使用C# WebClient连接到Firebase REST。示例:
using (WebClient webClient = new WebClient())
{
webClient.UploadString(restUrl, "PATCH", jsonDataString);
}
在中等负载下,它工作得很好,但是在某个时候我开始得到这个错误(错误立即抛出,没有延迟/超时)。
System.Net.WebException: The underlying connection was closed:
A connection that was expected
我需要找到方法来添加重试机制到我的数据库调用在超时的情况下,LINQ to SQL是用来调用我的代码中的一些sprocs…
using (MyDataContext dc = new MyDataContext())
{
int result = -1; //denote failure
int count = 0;
while ((result < 0) && (count < MAX_RETRIES))
{
result = dc.myStoredProc1(...);
count++;
我使用Polly (Microsoft.Extensions.Http.Polly)和.net核心进行此配置(使用无效的URL进行测试):
private static void RegisterServices()
{
var collection = new ServiceCollection();
var timeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(2); // Timeout for an individual try
collection.AddHttpClient<
我想重新发布x次处理失败的消息。我看到了手动提交代码:
val consumerWithOffsetSink = kafka.consumeWithOffsetSink(consumerProperties)
Source.fromPublisher(consumerWithOffsetSink.publisher)
.map(processMessage(_)) // your message processing
.to(consumerWithOffsetSink.offsetCommitSink) // stream back for commit
.run()
但是,如何处理proc
当我们生成消息时,我们可以定义回调,这个回调可能会出现异常:
kafkaProducer.send(producerRecord, new Callback() {
public void onCompletion(RecordMetadata recordMetadata, Exception e) {
if (e == null) {
// OK
} else {
// NOT OK
}
}
});
考虑到生产者中的buitl-in重试逻辑,我想知道开发人员应该明确地处理哪种异常?
由于卡夫卡制作人的各种原因,我经常得到超时异常。目前,我正在使用生产者配置的所有默认值。
我看到了以下超时异常:
60000 ms后,org.apache.kafka.common.errors.TimeoutException:未能更新元数据。
主题的org.apache.kafka.common.errors.TimeoutException:到期1(S)记录-1-0: 30001 ms自上一次追加以来已过。
我有以下问题:
这些超时异常的一般原因是什么?
1. Temporary network issue
2. Server issue? if yes then w