public void CreatesDefaultSqlCommandPolicyFromConfiguration()
        {
            RetryPolicy retryPolicy   = RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy();
            Incremental retryStrategy = retryPolicy.RetryStrategy as Incremental;

            Assert.AreEqual("Default SqlCommand Retry Strategy", retryStrategy.Name);
            Assert.IsInstanceOfType(retryPolicy.ErrorDetectionStrategy, typeof(SqlDatabaseTransientErrorDetectionStrategy));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the SQL Azure database-based persistence queue using the specified streaming mode, data type and buffer settings.
 /// </summary>
 /// <param name="streamingMode">The type of buffer that will be used for streaming operations.</param>
 /// <param name="streamingDataType">The type of data that will be used for streaming operations.</param>
 /// <param name="initialBufferSize">The initial size of the buffer where data is being collected before flushed into a SQL Azure database.</param>
 /// <param name="maxBufferSize">The maximum allowed size of the data buffer.</param>
 public SqlAzurePersistenceQueue(StreamingMode streamingMode, StreamingDataType streamingDataType, int initialBufferSize, int maxBufferSize)
 {
     this.streamingMode         = streamingMode;
     this.streamingDataType     = streamingDataType;
     this.initialBufferSize     = initialBufferSize;
     this.maxBufferSize         = maxBufferSize;
     this.connectionRetryPolicy = RetryPolicyFactory.GetDefaultSqlConnectionRetryPolicy();
     this.commandRetryPolicy    = RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy();
 }
 protected override void Act()
 {
     this.retryPolicy = RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy();
 }
Ejemplo n.º 4
0
 public RetryPolicy GetDefaultSqlCommandRetryPolicy()
 {
     return(RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy());
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the SqlAzureConnection class with a given connection string
 /// and a policy defining whether to retry a request if the connection fails to be opened or a command
 /// fails to be successfully executed.
 /// </summary>
 /// <param name="connectionString">The connection string used to open the SQL Azure database.</param>
 /// <param name="retryPolicy">The retry policy defining whether to retry a request if a connection or a command fails.</param>
 public ReliableSqlConnection(string connectionString, RetryPolicy retryPolicy)
     : this(connectionString, retryPolicy, ChooseBetween(RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy(), retryPolicy))
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Sends the specified command to the connection and builds a SqlDataReader object containing the results.
 /// Uses the default retry policy when executing the command.
 /// </summary>
 /// <param name="command">The command object which is required as per extension method declaration.</param>
 /// <returns>A System.Data.SqlClient.SqlDataReader object.</returns>
 public static SqlDataReader ExecuteReaderWithRetry(this SqlCommand command)
 {
     return(ExecuteReaderWithRetry(command, RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy()));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Executes a Transact-SQL statement against the connection and returns the number of rows affected. Uses the default retry policy when executing the command.
 /// </summary>
 /// <param name="command">The command object which is required as per extension method declaration.</param>
 /// <returns>The number of rows affected.</returns>
 public static int ExecuteNonQueryWithRetry(this SqlCommand command)
 {
     return(ExecuteNonQueryWithRetry(command, RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy()));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
 /// Uses the default retry policy when executing the command.
 /// </summary>
 /// <param name="command">The command object which is required as per extension method declaration.</param>
 /// <returns> The first column of the first row in the result set, or a null reference if the result set is empty. Returns a maximum of 2033 characters.</returns>
 public static object ExecuteScalarWithRetry(this SqlCommand command)
 {
     return(ExecuteScalarWithRetry(command, RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy()));
 }