/// <summary> /// Executes the specified queue manager. /// </summary> /// <param name="queueManager">The queue manager.</param> /// <returns></returns> public CommandResult Execute(IQueueManager queueManager) { try { if (this._retrySkipCount == 0) { this._attemptCount++; this.InternalExecute(); if (this._attemptCount > 1) { queueManager.LogEvent(EventLogEntryType.Information, 0x40004405L,Environment.MachineName); } return CommandResult.Success; } this._retrySkipCount--; return CommandResult.Retry; } catch (Exception exception) { var sqlException = exception as SqlException; var asyncServiceException = exception as AsyncServiceException; if ((sqlException == null) && (asyncServiceException == null)) { throw; } if (queueManager.ShuttingDown) { queueManager.LogEvent(EventLogEntryType.Error, 0xc0004409L, Environment.MachineName, exception.ToString() ); return CommandResult.Failure; } return CalculateRetryOrFailure(queueManager, exception); } }
/// <summary> /// Calculates the retry original failure. /// </summary> /// <param name="queueManager">The queue manager.</param> /// <param name="e">The decimal.</param> /// <returns></returns> private CommandResult CalculateRetryOrFailure(IQueueManager queueManager, Exception e) { if (this._attemptCount > queueManager.StateStatusUpdateMaxRetryCount) { if (this.RetryWithBackOff && DateTime.Now <= this._retryStartTime.AddDays(3.0)) return CommandResult.Retry; queueManager.LogEvent(EventLogEntryType.Error, 3221242886L, new object[] { Environment.MachineName, e.ToString() }); return CommandResult.Failure; } if (_attemptCount == 1) { queueManager.LogEvent(EventLogEntryType.Error, 2147501060L, new object[] { Environment.MachineName, queueManager.StateStatusUpdateMaxRetryCount, e.ToString() }); this._retryStartTime = DateTime.Now; } return CommandResult.Retry; }