-
Notifications
You must be signed in to change notification settings - Fork 954
[azservicebus] Fixing bug where you could lose messages in ReceiveAndDelete #24864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[azservicebus] Fixing bug where you could lose messages in ReceiveAndDelete #24864
Conversation
…ad left over credits before you closed.
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
|
/azp run go - azservicebus |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run go - azservicebus |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where messages may be lost in ReceiveAndDelete mode by allowing calls to ReceiveMessages even after the receiver is closed, draining any cached messages.
- Documentation and comments have been updated to reference new error types and behavior.
- Caching logic was added to the receiver to store prefetched messages and enable later retrieval.
- New tests and examples verify the new behavior and document proper usage.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/messaging/azservicebus/session_receiver.go | Updated documentation comments to reference new error types and settlement methods |
| sdk/messaging/azservicebus/sender.go | Updated error documentation in sender methods |
| sdk/messaging/azservicebus/receiver_test.go | Added new tests to verify cached message retrieval in ReceiveAndDelete mode |
| sdk/messaging/azservicebus/receiver.go | Introduced caching logic and the receiveFromCache helper to drain cached messages |
| sdk/messaging/azservicebus/message.go | Adjusted newReceivedMessage to safely handle nil receivers |
| sdk/messaging/azservicebus/internal/amqpLinks.go | Updated error handling to use a shared errClosed value and push cached messages after close |
| sdk/messaging/azservicebus/example_receiver_test.go | Added new example demonstrating the ReceiveAndDelete flow post-close |
| sdk/messaging/azservicebus/client.go | Updated documentation in session receiver creation methods |
| sdk/messaging/azservicebus/CHANGELOG.md | Added changelog entry detailing the bug fix |
…essages without some coordination.
|
/azp run go - azservicebus |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…s just get all 2000 and under normal conditions we do. However, it's not guaranteed so I've added an extra step to drain the queue of any remaining messages and check that we truly haven't lost anything.
|
/azp run go - azservicebus |
|
(Just a note, the test failure was just a problem with my test, not the package code) |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run go - azservicebus |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This PR makes it so you can call ReceiveMessages after a Receiver (only in ReceiveAndDelete mode) is closed, giving you access to any cached messages that might have arrived after your final ReceiveMessages() call, but before Close().
Fixes #24078