提交 ebdc770e 编写于 作者: R Rossen Stoyanchev

Use appropriate message id header for STOMP 1.1 vs 1.2

Issue: SPR-14391
上级 2cdcf752
...@@ -67,7 +67,6 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { ...@@ -67,7 +67,6 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
private static final Message<byte[]> HEARTBEAT; private static final Message<byte[]> HEARTBEAT;
static { static {
StompHeaderAccessor accessor = StompHeaderAccessor.createForHeartbeat(); StompHeaderAccessor accessor = StompHeaderAccessor.createForHeartbeat();
HEARTBEAT = MessageBuilder.createMessage(StompDecoder.HEARTBEAT_PAYLOAD, accessor.getMessageHeaders()); HEARTBEAT = MessageBuilder.createMessage(StompDecoder.HEARTBEAT_PAYLOAD, accessor.getMessageHeaders());
...@@ -93,6 +92,8 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { ...@@ -93,6 +92,8 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
private volatile TcpConnection<byte[]> connection; private volatile TcpConnection<byte[]> connection;
private volatile String version;
private final AtomicInteger subscriptionIndex = new AtomicInteger(); private final AtomicInteger subscriptionIndex = new AtomicInteger();
private final Map<String, DefaultSubscription> subscriptions = new ConcurrentHashMap<String, DefaultSubscription>(4); private final Map<String, DefaultSubscription> subscriptions = new ConcurrentHashMap<String, DefaultSubscription>(4);
...@@ -313,7 +314,12 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { ...@@ -313,7 +314,12 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
@Override @Override
public Receiptable acknowledge(String messageId, boolean consumed) { public Receiptable acknowledge(String messageId, boolean consumed) {
StompHeaders stompHeaders = new StompHeaders(); StompHeaders stompHeaders = new StompHeaders();
stompHeaders.setId(messageId); if ("1.1".equals(this.version)) {
stompHeaders.setMessageId(messageId);
}
else {
stompHeaders.setId(messageId);
}
String receiptId = checkOrAddReceipt(stompHeaders); String receiptId = checkOrAddReceipt(stompHeaders);
Receiptable receiptable = new ReceiptHandler(receiptId); Receiptable receiptable = new ReceiptHandler(receiptId);
...@@ -407,6 +413,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { ...@@ -407,6 +413,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
} }
else if (StompCommand.CONNECTED.equals(command)) { else if (StompCommand.CONNECTED.equals(command)) {
initHeartbeatTasks(stompHeaders); initHeartbeatTasks(stompHeaders);
this.version = stompHeaders.getFirst("version");
this.sessionFuture.set(this); this.sessionFuture.set(this);
this.sessionHandler.afterConnected(this, stompHeaders); this.sessionHandler.afterConnected(this, stompHeaders);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册