Skip to content

Commit

Permalink
Merge pull request #1709 from danielmarbach/try-add
Browse files Browse the repository at this point in the history
Safeguarding against duplicate sequence numbers
  • Loading branch information
lukebakken authored Oct 23, 2024
2 parents 43da301 + 9163bcc commit e51f6bc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/RabbitMQ.Client/Impl/Channel.PublisherConfirms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
if (_publisherConfirmationTrackingEnabled)
{
publisherConfirmationTcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
_confirmsTaskCompletionSources[publishSequenceNumber] = publisherConfirmationTcs;
if (!_confirmsTaskCompletionSources.TryAdd(publishSequenceNumber, publisherConfirmationTcs))
{
throw new InvalidOperationException($"Failed to track the publisher confirmation for sequence number '{publishSequenceNumber}' because it already exists.");
}
}

_nextPublishSeqNo++;
Expand Down

0 comments on commit e51f6bc

Please sign in to comment.