Closed danielmarbach closed 1 month ago
It might be worthwhile to stop passing the cancellation token in a few places before we approve this PR
It might be worthwhile to stop passing the cancellation token in a few places before we approve this PR
we looked at the released versions of the transport and recognized the cancellation token is always passed to the ack or nack methods. Keeping that consistent for now. We will not address this but raise an improvement issue.
Fixes https://github.com/Particular/NServiceBus.AzureStorageQueues/issues/1077
This PR follows through on related changes done in Amazon SQS but adjusts the core pieces of the change to Azure Storage Queue-specific behavior. Additionally, it brings in a number of layered tests that verify the code works as expected and doesn't accidentally break later.
And LRU cache to track the delivery attempts is not necessary because the receive count is automatically updated by the storage queue infrastructure.
The logic in
AtLeastOnceReceiveStrategy
has been updated significantly:BitFaster.Caching.Lru
) is introduced to keep track of messages that have been marked as successfully completed. This helps in avoiding unnecessary retries for messages that are already acknowledged.LeaseTimeoutException
). This is handled both when acknowledging a message (viaAck()
) and during error recovery. If a lease timeout occurs, the message is tracked for completion in the next receive attempt.QueueMessage
) through the context bag for further processing.Before
After
Tradeoffs
The tradeoffs are the sames as the other fixes applied in RabbitMQ and Amazon SQS. In competing consumer scenarios there can still be more retries because the LRU cache is in memory, but it is still marginally better than having a potentially unlimited number of retries.
As for the transaction mode
None
, there is no change required since we are not giving any guarantees there and messages are acknowledged early on.