如何在NHibernate的添加重试逻辑来处理在SQL Azure中瞬态故障? [英] How do I add Retry Logic in NHibernate to handle Transient Failures in SQL Azure?

查看:228
本文介绍了如何在NHibernate的添加重试逻辑来处理在SQL Azure中瞬态故障?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在Windows Azure上运行,并使用NHibernate的连接到SQL Azure数据库的.NET应用程序。有时是必要的,因为例如这里描述添加重试逻辑在SQL Azure中来处理临时故障 -

We have a .NET application that runs on Windows Azure and uses NHibernate to connect to a SQL Azure database. Sometimes it's necessary to add retry logic to handle transient failures in SQL Azure as described for example here -

<一个href=\"http://social.technet.microsoft.com/wiki/contents/articles/retry-logic-for-transient-failures-in-sql-azure.aspx\" rel=\"nofollow\">http://social.technet.microsoft.com/wiki/contents/articles/retry-logic-for-transient-failures-in-sql-azure.aspx

有人能指出我在与NHibernate这样的方法吗?理想情况下,我想这样做在NHibernate的水平,而不是包装每一个电话;我能为另一个ORM为此,.netTiers(http://nettiers.com),因为我在这里概述 -

Can someone point me to a way in doing this with NHibernate? Ideally I'd like to do this at the NHibernate level and not wrap every single call; I was able to do this for another ORM, .netTiers (http://nettiers.com) as I outline here -

http://blog.ehuna.org/2010/01/how_to_stop_getting_exceptions.html

我做了搜索,发现一些答案提及使用IDbCommand的接口的自定义实现 -

I did search and found some answers that mention using a custom implementation of the IDbCommand interface -

<一个href=\"http://stackoverflow.com/questions/6048835/intercept-sql-statements-containing-parameter-values-generated-by-nhibernate\">Intercept含NHibernate的生成的参数值的SQL语句

Intercept SQL statements containing parameter values generated by NHibernate

但我不知道这工作与NHibernate 3.2和我在寻找一个明显的例子,我可以修改。

But I'm not sure this works with NHibernate 3.2 and I'm looking for a clear example I could modify.

我如何才能让NHibernate的自动重试到SQL Azure的电话?比方说3次重,100毫秒每间等待 - 3重试后,若仍然失败,我们应该抛出该异常

How could I make NHibernate retry calls to SQL Azure automatically? Let's say 3 retries, with 100ms wait between each - after the 3 retries, if still failing, we should throw the exception.

推荐答案

我已经发布了用于完成这个库:

I've released a library that takes care of this:

https://github.com/robdmoore/NHibernate.SqlAzure

这篇关于如何在NHibernate的添加重试逻辑来处理在SQL Azure中瞬态故障?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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