Remove CONNECT-related message buffer from STOMP relay
Before this change, the StompProtocolHandler always responded to
clients with a CONNECTED frame, while the STOMP broker relay
independantly forwarded the client CONNECT to the broker and waited
for the CONNECTED frame back. That meant the relay had to buffer
client messages until it received the CONNECTED response from
the message broker.
This change ensures that clients wait for a CONNECTED frame from
the message broker. The broker relay forwards the CONNECT frame to
the broker. The broker responds with a CONNECTED frame, which the
relay then forwards to the client. As a result, a (well-written)
client will not send any messages to the relay until the connection
to the broker is fully established.
The StompProtcolHandler can now be configured whether to send CONNECTED
frame back. By default that is off. So when using the simple broker,
the StompProtocolHandler can still respond with CONNECTED frames.
The relay's handling of a connection being dropped has also been
improved. When a connection for a client relay session is dropped
an ERROR frame will be sent back to the client. If a connection is
closed as part of a DISCONNECT frame being sent, no ERROR frame
is sent back to the client. When the connection for the system relay
session is dropped, an event is published indicating that the broker
is unavailable. Reactor's TcpClient will then attempt to re-restablish
the connection.
pull/364/merge
Andy Wilkinson13 years agocommitted byRossen Stoyanchev
@ -54,7 +54,8 @@ public class ServletStompEndpointRegistry implements StompEndpointRegistry {
@@ -54,7 +54,8 @@ public class ServletStompEndpointRegistry implements StompEndpointRegistry {
@ -63,6 +64,7 @@ public class ServletStompEndpointRegistry implements StompEndpointRegistry {
@@ -63,6 +64,7 @@ public class ServletStompEndpointRegistry implements StompEndpointRegistry {
@ -57,8 +57,10 @@ public abstract class WebSocketMessageBrokerConfigurationSupport {
@@ -57,8 +57,10 @@ public abstract class WebSocketMessageBrokerConfigurationSupport {
@ -249,12 +245,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -249,12 +245,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
Assert.notNull(sessionId,"sessionId is required");
@ -291,6 +283,12 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -291,6 +283,12 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@ -307,12 +305,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -307,12 +305,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@ -344,24 +338,11 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -344,24 +338,11 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@ -381,6 +362,12 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -381,6 +362,12 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
logger.trace("Forwarding to STOMP broker, message: "+message);
@ -396,7 +383,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -396,7 +383,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
handleTcpClientFailure("Timed out waiting for message to be forwarded to the broker",null);
handleTcpClientFailure("Failed to forward message to the broker",null);
}
}
@ -408,13 +395,10 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -408,13 +395,10 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@ -461,6 +445,10 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -461,6 +445,10 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@ -473,7 +461,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -473,7 +461,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@ -488,6 +476,11 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@@ -488,6 +476,11 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@ -70,6 +70,7 @@ public class StompProtocolHandler implements SubProtocolHandler {
@@ -70,6 +70,7 @@ public class StompProtocolHandler implements SubProtocolHandler {
@ -86,6 +87,29 @@ public class StompProtocolHandler implements SubProtocolHandler {
@@ -86,6 +87,29 @@ public class StompProtocolHandler implements SubProtocolHandler {
@ -121,17 +145,17 @@ public class StompProtocolHandler implements SubProtocolHandler {
@@ -121,17 +145,17 @@ public class StompProtocolHandler implements SubProtocolHandler {
logger.error("Terminating STOMP session due to failure to send message: ",t);
sendErrorMessage(session,t);
}
}
/**
@ -144,8 +168,8 @@ public class StompProtocolHandler implements SubProtocolHandler {
@@ -144,8 +168,8 @@ public class StompProtocolHandler implements SubProtocolHandler {
@ -63,16 +62,14 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -63,16 +62,14 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@ -86,6 +83,14 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -86,6 +83,14 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@ -102,22 +107,24 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -102,22 +107,24 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@ -129,7 +136,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -129,7 +136,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@ -137,37 +144,31 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -137,37 +144,31 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@ -176,37 +177,55 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -176,37 +177,55 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
// Check that we have not received an ERROR as a result of the connection closing
this.responseHandler.awaitAndAssert();
*/
}
@ -234,58 +253,66 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -234,58 +253,66 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@ -352,22 +379,28 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -352,22 +379,28 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@ -515,35 +548,48 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@@ -515,35 +548,48 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {