我应该通过 Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling 重试吗
Should I retry through Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling
我有一些旧代码,使用 EnterpriseLibrary.TransientFaultHandling 包实现对 Azure 服务总线主题的重试:
var bus = TopicClient.CreateFromConnectionString(con, topic);
await new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(
new FixedInterval(3, TimeSpan.FromMilliseconds(200)))
.ExecuteAsync(() =>
await bus.SendAsync(msg)
...
该代码是多年前编写的,可能取自博客 post 或某些 Microsoft 文档。当检查今天的 TopicClient
时,它包含一个名为 RetryPolicy
的 属性,默认设置为 RetryExponential
的实例,具有重试次数、最大超时的一些默认值等
在我看来,TopicClient
上的默认重试策略看起来不错。使用 TransientFaultHandling 在重试中包装它有什么好处吗?如果我想要更多重试或其他重试策略,我可以直接在主题客户端上简单地配置另一个重试策略,而不是将两个重试策略包装在一起。
I can simply configure another retry strategy directly on the topic client, rather than wrapping two retry strategies together.
这就是为什么 RetryPolicy
found with Azure Service Bus .NET 客户端被创建并能够重新配置以满足您的需求。您不必引入第 3 方重试,除非在内置重试策略不能满足您的需要的情况下确实需要它。
我有一些旧代码,使用 EnterpriseLibrary.TransientFaultHandling 包实现对 Azure 服务总线主题的重试:
var bus = TopicClient.CreateFromConnectionString(con, topic);
await new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(
new FixedInterval(3, TimeSpan.FromMilliseconds(200)))
.ExecuteAsync(() =>
await bus.SendAsync(msg)
...
该代码是多年前编写的,可能取自博客 post 或某些 Microsoft 文档。当检查今天的 TopicClient
时,它包含一个名为 RetryPolicy
的 属性,默认设置为 RetryExponential
的实例,具有重试次数、最大超时的一些默认值等
在我看来,TopicClient
上的默认重试策略看起来不错。使用 TransientFaultHandling 在重试中包装它有什么好处吗?如果我想要更多重试或其他重试策略,我可以直接在主题客户端上简单地配置另一个重试策略,而不是将两个重试策略包装在一起。
I can simply configure another retry strategy directly on the topic client, rather than wrapping two retry strategies together.
这就是为什么 RetryPolicy
found with Azure Service Bus .NET 客户端被创建并能够重新配置以满足您的需求。您不必引入第 3 方重试,除非在内置重试策略不能满足您的需要的情况下确实需要它。