使用重试机制处理 wcf 连接中的故障的标准方法是什么,特别是针对 azure 服务总线?
What is the standard way to handle faults in a wcf connection with a retry mechanism, specifically for azure service bus?
我查看了示例代码 here here 以了解如何处理 azure 中继的连接问题。他们在 Microsoft.Practices.TransientFaultHandling
中使用指数退避机制来处理故障连接的重建:
retryStrategy = new ExponentialBackoff(100000, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60),
TimeSpan.FromSeconds(1));
...
...
var shouldRetry = retryStrategy.GetShouldRetry();
if (shouldRetry(retryCount++, statusBehavior.LastError, out waitPeriod))
{
Thread.Sleep(waitPeriod);
Open();
Console.WriteLine("Relay Echo ServiceHost recreated ");
}
经过更多研究,我注意到根据 Microsoft.Practices.TransientFaultHandling 上的页面:
This content and the technology described is outdated and is no longer being maintained. For more information, see Transient Fault Handling.
那么,根据link暂时性故障处理,它表示:
Important: Recent versions of SDKs for both Azure Storage and Azure Service Bus natively support retries. It is recommended to use these instead of the Transient Fault Handling Application Block
但是,我没有在任何地方看到任何关于如何实现与示例类似的行为的示例,而是使用 Azure 服务总线 SDK 重试 class(es)。实现这个的标准方法是什么?或者,上面的引述是不是已经为 wcf 连接内置了重试机制,这样我就不需要担心重新创建我的 WebServiceHost
及其相应的连接?
我在尝试了几种不同的解决方案后回答了这个问题,我认为目前最好的方法是只使用最近更新的 Microsoft Transient Fault Handling Library instead of the old deprecated Microsoft.Practices.TransientFaultHandling
. This library has similar functionality to the deprecated one currently being used in the sample here here,以及提供的其余解决方案因为指数退避仍然可以与这个更新的(虽然绝对不是新的)库几乎相同。如果 Microsoft 认为这不是将来要走的路,希望他们会更新他们的 azure relay 示例以显示推荐的解决方案或解决方案。然后,我可以更新这个答案。
我查看了示例代码 here here 以了解如何处理 azure 中继的连接问题。他们在 Microsoft.Practices.TransientFaultHandling
中使用指数退避机制来处理故障连接的重建:
retryStrategy = new ExponentialBackoff(100000, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60),
TimeSpan.FromSeconds(1));
...
...
var shouldRetry = retryStrategy.GetShouldRetry();
if (shouldRetry(retryCount++, statusBehavior.LastError, out waitPeriod))
{
Thread.Sleep(waitPeriod);
Open();
Console.WriteLine("Relay Echo ServiceHost recreated ");
}
经过更多研究,我注意到根据 Microsoft.Practices.TransientFaultHandling 上的页面:
This content and the technology described is outdated and is no longer being maintained. For more information, see Transient Fault Handling.
那么,根据link暂时性故障处理,它表示:
Important: Recent versions of SDKs for both Azure Storage and Azure Service Bus natively support retries. It is recommended to use these instead of the Transient Fault Handling Application Block
但是,我没有在任何地方看到任何关于如何实现与示例类似的行为的示例,而是使用 Azure 服务总线 SDK 重试 class(es)。实现这个的标准方法是什么?或者,上面的引述是不是已经为 wcf 连接内置了重试机制,这样我就不需要担心重新创建我的 WebServiceHost
及其相应的连接?
我在尝试了几种不同的解决方案后回答了这个问题,我认为目前最好的方法是只使用最近更新的 Microsoft Transient Fault Handling Library instead of the old deprecated Microsoft.Practices.TransientFaultHandling
. This library has similar functionality to the deprecated one currently being used in the sample here here,以及提供的其余解决方案因为指数退避仍然可以与这个更新的(虽然绝对不是新的)库几乎相同。如果 Microsoft 认为这不是将来要走的路,希望他们会更新他们的 azure relay 示例以显示推荐的解决方案或解决方案。然后,我可以更新这个答案。