我使用以下代碼:什麼是Microsoft.Practices.TransientFaultHandling.RetryPolicy的正確代碼?
創建一個重試策略,當出現錯誤時,在1秒後重試,然後等待3秒,然後等待5秒鐘。基於Azure的SLA,重試10秒必須成功之內(不節流,我確信這一點。因爲錯誤甚至發生在獨特的分區表,沒有交通還)
var retryStrategy = new Incremental(3, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
var FaultHandlingRetryPolicy = new RetryPolicy<StorageTransientErrorDetectionStrategy>(retryStrategy);
然後我用這個代碼來獲取數據
FaultHandlingRetryPolicy .ExecuteAction(() =>
{
var results = (from q in Query select new q).ToList();
});
我不,如果它的重試還是不行,知道是因爲錯誤日誌未顯示
錯誤:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 70.37.127.112:443
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.Data.Services.Client.QueryResult.Execute()
at System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
at System.Data.Services.Client.DataServiceQuery`1.Execute()
at System.Data.Services.Client.DataServiceQuery`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.Practices.TransientFaultHandling.RetryPolicy.<>c__DisplayClass1.<ExecuteAction>b__0()
at Microsoft.Practices.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
請讓我知道如果這個代碼將重試,感謝
順便說一句,我在MS一個古老的線程這也http://social.msdn.microsoft.com/Forums/en-US/windowsazuretroubleshooting/thread/b55d0126-f80b-4df2-bcb6-8b5da37c51ff – 2012-03-28 09:27:25