Overloaded acknowledge method with StompHeaders

Issue: SPR-16519
This commit is contained in:
Mariusz Jasinski
2018-02-27 16:42:48 +01:00
committed by Rossen Stoyanchev
parent 7bce04c06c
commit 184ed6da57
2 changed files with 22 additions and 2 deletions

View File

@@ -328,12 +328,19 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
stompHeaders.setId(messageId);
}
String receiptId = checkOrAddReceipt(stompHeaders);
Receiptable receiptable = acknowledge(stompHeaders, consumed);
return receiptable;
}
@Override
public Receiptable acknowledge(StompHeaders headers, boolean consumed) {
String receiptId = checkOrAddReceipt(headers);
Receiptable receiptable = new ReceiptHandler(receiptId);
StompCommand command = (consumed ? StompCommand.ACK : StompCommand.NACK);
StompHeaderAccessor accessor = createHeaderAccessor(command);
accessor.addNativeHeaders(stompHeaders);
accessor.addNativeHeaders(headers);
Message<byte[]> message = createMessage(accessor, null);
execute(message);

View File

@@ -101,6 +101,19 @@ public interface StompSession {
*/
Receiptable acknowledge(String messageId, boolean consumed);
/**
* Send an acknowledgement whether a message was consumed or not resulting
* in an ACK or NACK frame respectively.
* <p><strong>Note:</strong> to use this when subscribing you must set the
* {@link StompHeaders#setAck(String) ack} header to "client" or
* "client-individual" in order ot use this.
* @param headers the headers for the ACK or NACK frame
* @param consumed whether the message was consumed or not
* @return a Receiptable for tracking receipts
* @since 5.1
*/
Receiptable acknowledge(StompHeaders headers, boolean consumed);
/**
* Disconnect the session by sending a DISCONNECT frame.
*/