Skip to content

gh-22729: Make StompSession.Subscription.unsubscribe() return Receiptable #35224

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Songdoeon
Copy link

Motivation

Currently Subscription.unsubscribe() is a void method, so clients have no way to know when an UNSUBSCRIBE frame has actually been processed by the server. This PR brings unsubscribe() in line with send() and acknowledge() by returning a Receiptable that callers can use to register callbacks and track the receipt.

Summary of Changes

  • Interface

    • StompSession.Subscription — both unsubscribe() overloads now return Receiptable instead of void.
  • Implementation

    • DefaultStompSession.unsubscribe(String, StompHeaders) (private helper) now returns a Receiptable by creating a ReceiptHandler after adding a receipt-id header.
    • DefaultStompSession.DefaultSubscription.unsubscribe(...) now invokes the helper and simply returns its Receiptable.
  • Tests (in DefaultStompSessionTests)

    • unsubscribeWithReceipt()
      Verifies that calling unsubscribe() returns a non‑null Receiptable 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 returned Receiptable 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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 20, 2025
@Songdoeon Songdoeon force-pushed the issue/22729-unsubscribe-receiptable branch 2 times, most recently from 04bac3f to 39760ed Compare July 20, 2025 07:53
Signed-off-by: Songdoeon <ehdjs9583@naver.com>
Signed-off-by: Songdoeon <ehdjs9583@naver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make StompSession.Subscription.unsubscribe() to return Receiptable
2 participants