/// <summary> /// Breaks the lock (forces a lock to unlock) asynchronously. /// </summary> /// <param name="state">The lock state object.</param> /// <param name="cancelToken">An optional cancellation token.</param> /// <returns>The lock state object, updated after the operation.</returns> public async Task <AzureLockState> BreakLockAsync(AzureLockState state, CancellationToken cancelToken) { Guard.NotNull(state, "state"); CloudToolsStorageException exception = null; try { // TODO: What if does not exist already, Exceptions await(state.LeaseId != null ? this.UnregisterLockAsync(state, cancelToken) : this.BreakLockInternal(state, cancelToken)).ConfigureAwait(false); } catch (CloudToolsStorageException ex) { exception = ex; } if (exception != null && (exception.StatusCode == 409 || exception.StatusCode == 412)) { this.BreakLockInternal(state, cancelToken).Wait(cancelToken); } return(state); }
protected internal override void HandleStorageExceptions(HandleMessagesOptionsBase messageOptions, CloudToolsStorageException ex) { this.DecoratedQueue.HandleStorageExceptions(messageOptions, ex); }
/// <summary> /// Defines a handler for storage related exceptions /// </summary> /// <param name="messageOptions">The options of this extended queue.</param> /// <param name="exception">The <see cref="CloudToolsStorageException"/> that occurred.</param> protected internal virtual void HandleStorageExceptions([CanBeNull] HandleMessagesOptionsBase messageOptions, [CanBeNull] CloudToolsStorageException exception) { if (Guard.IsAnyNull(messageOptions, exception)) { return; } this.Statistics.IncreaseCriticallyFaultedMessages(); this.Statistics.IncreaseReenqueuesCount(); try { if (messageOptions.ExceptionHandler != null) { messageOptions.ExceptionHandler(exception); this.Top.LogException(LogSeverity.Info, exception, "An unexpected storage exception occurred while processing messages on queue '{0}' and was handled", this.Name); } else { this.Top.LogException(LogSeverity.Warning, exception, "An unexpected storage exception occurred while processing messages on queue '{0}' but was not handled!", this.Name); } } catch (Exception innerEx) { this.Top.LogException(LogSeverity.Error, innerEx, "An unexpected exception occurred within the storage exception handler on queue '{0}'", this.Name); } }