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:
@@ -39,6 +39,8 @@ public enum SimpMessageType {
|
||||
|
||||
DISCONNECT,
|
||||
|
||||
DISCONNECT_ACK,
|
||||
|
||||
OTHER;
|
||||
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user