Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had an idea this morning based on the changes in #546, so I thought I'd see how far I could get with it and submit a PR for discussion.
In the event that the issue that lead to #546 occurring and tasks to process messages back up, it's possible that a task to process a message may be trying to process a message that was received so long ago that the message visibility timeout has expired and it is now a potential duplicate waiting to be processed.
If the handler had a
CancellationToken
that cancels after the approximate message visibility timeout expires, JustSaying could enable two behaviours:false
to send it back to the queue (where it could have since been handled elsewhere anyway), or it could returntrue
on the basis, if this has expired I'll just ignore it and pretend I've dealt with it.This is implemented here by adding the
ICancellableHandlerAsync<T>
interface that derives fromIHandlerAsync<T>
, and then plumbing it in appropriately so it's used if implemented by the handler for a particular message and extending things like the exactly-once handler and stopwatch wrappers.There's also some random bits of refactoring in here that happened as I was going along, I'll pull those out into a separate PR shortly.