Skip to content

Commit a109d6a

Browse files
committed
Set heartbeat to 0,0 on CONNECT to message broker
1 parent 6eea4ad commit a109d6a

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,36 @@ public void handleMessage(Message<?> message) {
292292

293293
try {
294294
if ((destination == null) || supportsDestination(destination)) {
295+
295296
if (logger.isTraceEnabled()) {
296297
logger.trace("Processing message: " + message);
297298
}
298-
handleInternal(message, messageType, sessionId);
299+
300+
if (SimpMessageType.CONNECT.equals(messageType)) {
301+
headers.setHeartbeat(0, 0); // TODO: disable for now
302+
message = MessageBuilder.withPayloadAndHeaders(message.getPayload(), headers).build();
303+
RelaySession session = new RelaySession(sessionId);
304+
this.relaySessions.put(sessionId, session);
305+
session.open(message);
306+
}
307+
else if (SimpMessageType.DISCONNECT.equals(messageType)) {
308+
RelaySession session = this.relaySessions.remove(sessionId);
309+
if (session == null) {
310+
if (logger.isTraceEnabled()) {
311+
logger.trace("Session already removed, sessionId=" + sessionId);
312+
}
313+
return;
314+
}
315+
session.forward(message);
316+
}
317+
else {
318+
RelaySession session = this.relaySessions.get(sessionId);
319+
if (session == null) {
320+
logger.warn("Session id=" + sessionId + " not found. Ignoring message: " + message);
321+
return;
322+
}
323+
session.forward(message);
324+
}
299325
}
300326
}
301327
catch (Throwable t) {
@@ -312,32 +338,6 @@ protected boolean supportsDestination(String destination) {
312338
return false;
313339
}
314340

315-
protected void handleInternal(Message<?> message, SimpMessageType messageType, String sessionId) {
316-
if (SimpMessageType.CONNECT.equals(messageType)) {
317-
RelaySession session = new RelaySession(sessionId);
318-
this.relaySessions.put(sessionId, session);
319-
session.open(message);
320-
}
321-
else if (SimpMessageType.DISCONNECT.equals(messageType)) {
322-
RelaySession session = this.relaySessions.remove(sessionId);
323-
if (session == null) {
324-
if (logger.isTraceEnabled()) {
325-
logger.trace("Session already removed, sessionId=" + sessionId);
326-
}
327-
return;
328-
}
329-
session.forward(message);
330-
}
331-
else {
332-
RelaySession session = this.relaySessions.get(sessionId);
333-
if (session == null) {
334-
logger.warn("Session id=" + sessionId + " not found. Ignoring message: " + message);
335-
return;
336-
}
337-
session.forward(message);
338-
}
339-
}
340-
341341

342342
private class RelaySession {
343343

0 commit comments

Comments
 (0)