gh-22729: Make StompSession.Subscription.unsubscribe() return Receiptable #35224
+92
−10
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.
Motivation
Currently
Subscription.unsubscribe()
is avoid
method, so clients have no way to know when an UNSUBSCRIBE frame has actually been processed by the server. This PR bringsunsubscribe()
in line withsend()
andacknowledge()
by returning aReceiptable
that callers can use to register callbacks and track the receipt.Summary of Changes
Interface
StompSession.Subscription
— bothunsubscribe()
overloads now returnReceiptable
instead ofvoid
.Implementation
DefaultStompSession.unsubscribe(String, StompHeaders)
(private helper) now returns aReceiptable
by creating aReceiptHandler
after adding a receipt-id header.DefaultStompSession.DefaultSubscription.unsubscribe(...)
now invokes the helper and simply returns itsReceiptable
.Tests (in
DefaultStompSessionTests
)unsubscribeWithReceipt()
Verifies that calling
unsubscribe()
returns a non‑nullReceiptable
and that the sent frame still only contains the subscription ID when auto‑receipt is off.unsubscribeWithCustomHeaderAndReceipt()
Verifies that with
autoReceipt=true
and custom headers, the UNSUBSCRIBE frame contains the subscription ID, the custom header, and the generated receipt header, and that the returnedReceiptable
holds the same receipt-id.receiptReceivedOnUnsubscribe()
Verifies that if a RECEIPT frame arrives for the receipt-id, a task registered on the returned
Receiptable
is executed.All existing tests pass, and the new tests cover the added behavior.
Closes gh-22729