As suggested by Service Bus team in the service bus runtime driven scaling investigation (ICM ticket),
message = await _receiver.Value.PeekAsync()
intends to peek the first message . However, in this usage, the client remembera the sequence number of the last message and peeks the next message on the next call. For example, if there are two messages in the queue, calling peekAsync returns the first message. If you call peekAsync again, it returns the second message. If you call peekAsync again, it will return no message or null.
Use PeekBySequenceNumberAsync instead so it forces the client to check the first message from sequence number =0.
Repro:
drop two message on the service bus queue/topic
reuse the service bus message receiver and call peek async three times
Repro-ed and verified the PeekBySequenceNumberAsync would switch to the desired behavior.
Pull request checklist
[x] My changes do not require documentation changes
[ ] Otherwise: Documentation issue linked to PR. Update documentation to reflect new configuration options
[x] My changes should not be added to the release notes for the next release
[ ] Otherwise: I've added my notes to release_notes.md
[x] My changes do not need to be backported to a previous version
[ ] Otherwise: Backport tracked by issue/PR #issue_or_pr
[ ] I have added all required tests (Unit tests, E2E tests)
As suggested by Service Bus team in the service bus runtime driven scaling investigation (ICM ticket),
message = await _receiver.Value.PeekAsync()
intends to peek the first message . However, in this usage, the client remembera the sequence number of the last message and peeks the next message on the next call. For example, if there are two messages in the queue, calling peekAsync returns the first message. If you call peekAsync again, it returns the second message. If you call peekAsync again, it will return no message or null.
Use PeekBySequenceNumberAsync instead so it forces the client to check the first message from sequence number =0.
Repro:
Repro-ed and verified the PeekBySequenceNumberAsync would switch to the desired behavior.
Pull request checklist
release_notes.md