Simple broker sends notice after disconnect

Before this change the simple broker simply removed subscriptions
upon receiving a DISCONNECT message assuming it was a result of
a client STOMP WebSocket session ending.

However, if the server-side application sends a DISCONNECT to
the broker in order to terminate a session, the STOMP WebSocket
session could remain unware without any further action. This
change ensures the simple broker sends a DISCONNECT_ACK message
downstream whenever it receives a DISCONNECT.

Issue: SPR-12288
This commit is contained in:
Rossen Stoyanchev
2014-10-23 21:55:16 -04:00
parent 6463878f2d
commit 01aa64c534
4 changed files with 21 additions and 5 deletions

View File

@@ -39,6 +39,8 @@ public enum SimpMessageType {
DISCONNECT,
DISCONNECT_ACK,
OTHER;
}

View File

@@ -169,6 +169,11 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
logger.debug("Processing " + accessor.getShortLogMessage(EMPTY_PAYLOAD));
}
this.subscriptionRegistry.unregisterAllSubscriptions(sessionId);
SimpMessageHeaderAccessor disconnectAck = SimpMessageHeaderAccessor.create(SimpMessageType.DISCONNECT_ACK);
initHeaders(disconnectAck);
disconnectAck.setSessionId(sessionId);
Message<byte[]> messageOut = MessageBuilder.createMessage(EMPTY_PAYLOAD, disconnectAck.getMessageHeaders());
getClientOutboundChannel().send(messageOut);
}
else if (SimpMessageType.SUBSCRIBE.equals(messageType)) {
if (logger.isDebugEnabled()) {