private async Task ReleaseMessageAsync(IStorageQueueMessage message, CancellationToken cancellationToken) { try { // We couldn't process the message. Let someone else try. await _queue.UpdateMessageAsync(message, TimeSpan.Zero, MessageUpdateFields.Visibility, cancellationToken); } catch (StorageException exception) { if (exception.IsBadRequestPopReceiptMismatch()) { // Someone else already took over the message; no need to do anything. return; } else if (exception.IsNotFoundMessageOrQueueNotFound() || exception.IsConflictQueueBeingDeletedOrDisabled()) { // The message or queue is gone, or the queue is down; no need to release the message. return; } else { throw; } } }
public async Task <TaskSeriesCommandResult> ExecuteAsync(CancellationToken cancellationToken) { TimeSpan delay; try { await _queue.UpdateMessageAsync(_message, _visibilityTimeout, MessageUpdateFields.Visibility, cancellationToken); // The next execution should occur after a normal delay. delay = _speedupStrategy.GetNextDelay(executionSucceeded: true); } catch (StorageException exception) { // For consistency, the exceptions handled here should match PollQueueCommand.DeleteMessageAsync. if (exception.IsServerSideError()) { // The next execution should occur more quickly (try to update the visibility before it expires). delay = _speedupStrategy.GetNextDelay(executionSucceeded: false); } if (exception.IsBadRequestPopReceiptMismatch()) { // There's no point to executing again. Once the pop receipt doesn't match, we've permanently lost // ownership. delay = Timeout.InfiniteTimeSpan; } else if (exception.IsNotFoundMessageOrQueueNotFound() || exception.IsConflictQueueBeingDeletedOrDisabled()) { // There's no point to executing again. Once the message or queue is deleted, we've permanently lost // ownership. // For queue disabled, in theory it's possible the queue could be re-enabled, but the scenarios here // are currently unclear. delay = Timeout.InfiniteTimeSpan; } else { throw; } } return(new TaskSeriesCommandResult(wait: Task.Delay(delay))); }
protected override async Task ReleaseMessageAsync(CloudQueueMessage message, FunctionResult result, TimeSpan visibilityTimeout, CancellationToken cancellationToken) { FakeStorageQueueMessage fakeMessage = new FakeStorageQueueMessage(message); await _queue.UpdateMessageAsync(fakeMessage, visibilityTimeout, MessageUpdateFields.Visibility, cancellationToken); }