@@ -345,14 +345,24 @@ public Receiptable acknowledge(StompHeaders headers, boolean consumed) {
345
345
return receiptable ;
346
346
}
347
347
348
- private void unsubscribe (String id , @ Nullable StompHeaders headers ) {
349
- StompHeaderAccessor accessor = createHeaderAccessor (StompCommand .UNSUBSCRIBE );
350
- if (headers != null ) {
351
- accessor .addNativeHeaders (headers );
348
+ private Receiptable unsubscribe (String id , @ Nullable StompHeaders headers ) {
349
+ Assert .hasText (id , "Subscription id is required" );
350
+
351
+ if (headers == null ){
352
+ headers = new StompHeaders ();
352
353
}
354
+
355
+ String receiptId = checkOrAddReceipt (headers );
356
+ Receiptable receiptable = new ReceiptHandler (receiptId );
357
+
358
+ StompHeaderAccessor accessor = createHeaderAccessor (StompCommand .UNSUBSCRIBE );
359
+ accessor .addNativeHeaders (headers );
353
360
accessor .setSubscriptionId (id );
361
+
354
362
Message <byte []> message = createMessage (accessor , EMPTY_PAYLOAD );
355
363
execute (message );
364
+
365
+ return receiptable ;
356
366
}
357
367
358
368
@ Override
@@ -674,17 +684,19 @@ public StompFrameHandler getHandler() {
674
684
}
675
685
676
686
@ Override
677
- public void unsubscribe () {
678
- unsubscribe (null );
687
+ public Receiptable unsubscribe () {
688
+ return unsubscribe (null );
679
689
}
680
690
681
691
@ Override
682
- public void unsubscribe (@ Nullable StompHeaders headers ) {
692
+ public Receiptable unsubscribe (@ Nullable StompHeaders headers ) {
683
693
String id = this .headers .getId ();
694
+ Receiptable receiptable = new ReceiptHandler (null );
684
695
if (id != null ) {
685
696
DefaultStompSession .this .subscriptions .remove (id );
686
- DefaultStompSession .this .unsubscribe (id , headers );
697
+ receiptable = DefaultStompSession .this .unsubscribe (id , headers );
687
698
}
699
+ return receiptable ;
688
700
}
689
701
690
702
@ Override
0 commit comments