Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Do not attempt to abandon the message if we know that the message / s…
Browse files Browse the repository at this point in the history
…ession lock is already lost. (#256)

* Do not attempt to abandon the message if we know that the message / session lock is already lost.

* Releasing lock after abandon()
  • Loading branch information
nemakam authored and binzywu committed Aug 5, 2017
1 parent d3305ce commit 7cd009c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Microsoft.Azure.ServiceBus/MessageReceivePump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,14 @@ async Task MessageDispatchTask(Message message)
{
MessagingEventSource.Log.MessageReceiverPumpUserCallbackException(this.messageReceiver.ClientId, message, exception);
await this.RaiseExceptionReceived(exception, ExceptionReceivedEventArgsAction.UserCallback).ConfigureAwait(false);

// Nothing much to do if UserCallback throws, Abandon message and Release semaphore.
await this.AbandonMessageIfNeededAsync(message).ConfigureAwait(false);
if (!(exception is MessageLockLostException))
{
await this.AbandonMessageIfNeededAsync(message).ConfigureAwait(false);
}

// AbandonMessageIfNeededAsync should take care of not throwing exception
this.maxConcurrentCallsSemaphoreSlim.Release();
return;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Microsoft.Azure.ServiceBus/SessionReceivePump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ async Task MessagePumpTaskAsync(IMessageSession session)
MessagingEventSource.Log.MessageReceivePumpTaskException(this.clientId, session.SessionId, exception);
await this.RaiseExceptionReceived(exception, ExceptionReceivedEventArgsAction.UserCallback).ConfigureAwait(false);
callbackExceptionOccured = true;
await this.AbandonMessageIfNeededAsync(session, message).ConfigureAwait(false);
if (!(exception is MessageLockLostException || exception is SessionLockLostException))
{
await this.AbandonMessageIfNeededAsync(session, message).ConfigureAwait(false);
}
}
finally
{
Expand Down

0 comments on commit 7cd009c

Please sign in to comment.