Browse Source

Overloaded acknowledge method with StompHeaders

Issue: SPR-16519
pull/1708/head
Mariusz Jasinski 8 years ago committed by Rossen Stoyanchev
parent
commit
184ed6da57
  1. 11
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java
  2. 13
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java

11
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java

@ -328,12 +328,19 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { @@ -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);

13
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java

@ -101,6 +101,19 @@ public interface StompSession { @@ -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.
*/

Loading…
Cancel
Save