从1.x的升级Windows Azure的服务总线2.0 - 重试政策 [英] upgrading Windows Azure Service Bus from 1.x to 2.0 - Retry Policy

查看:236
本文介绍了从1.x的升级Windows Azure的服务总线2.0 - 重试政策的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要通过努力提高code使用旧的Windows Azure服务总线(pre 2.0)。

I am going through an effort to upgrade code that used the old Windows Azure Service Bus (pre 2.0).

根据此code使用的企业库瞬态故障处理模块提供调用到服务总线API时发送和接收队列中的消息被利用重试的政策。

This code based used the Enterprise Library Transient Fault Handling blocks to provide a retry policy that is leveraged when calling into the Service Bus API to send and receive queue messages.

通常情况下,code是这样的(减去所有的try / catch /终于等):

Typically the code would look like this (minus all the try/catch/finally, etc.):

 retryPolicy.Execute(() =>  { queueClient.Send(msg); });

然而,在服务总线2.0,重试的政策建立在工厂的消息,这样我就可以设置:

However, in Service Bus 2.0, retry policy is built into the messaging factory, so I can set:

_msgFactory.RetryPolicy = RetryExponential.Default;
var queueClient = _msgFactory.CreateQueueClient(path, mode);

一旦做到这一点,我可以删除TFH重试政策的execute()调用周围的包装,以 queueClient.Send(MSG)。

这是真的要保证队列客户端是短暂的例外重试所需要的?似乎简单。我怎么能证明它是重试?

Is this really all that is needed to ensure the queue client is retrying on transient exceptions? Seems to simple. How can I prove that it is retrying?

推荐答案

这的确是所有你需要做的;)它是不容易模仿,将被处理瞬态错误。也许在很短的网络问题(虽然我不知道该客户端的连接问题将被视为瞬态)

that is indeed all you need to do ;) it's not easy to simulate errors that will be handled transient. maybe a very short network issue (although I'm not sure that client side connection issues will be seen as transient)

这篇关于从1.x的升级Windows Azure的服务总线2.0 - 重试政策的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆