Improve handling of send failures
Prior to this commit, a failure to send a heartbeat was ignored and a failure to forward a message to the broker would result in an error frame being sent but nothing more. Following this commit, a failure to send a heartbeat to the broker is treated as a TCP client failure. Furthermore, if the system relay session fails to forward a message to the broker an exception is thrown. Typically, the system relay session will be forwarding messages on behalf of local application code, rather than a remote WebSocket client. Throwing an exception allows the application code to be notified of the problem directly, rather than via a broker availability event.
This commit is contained in:
committed by
Rossen Stoyanchev
parent
9b2c041085
commit
b2f31a3c74
@@ -33,6 +33,7 @@ import org.junit.Test;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.simp.BrokerAvailabilityEvent;
|
||||
@@ -143,6 +144,12 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
||||
this.responseHandler.awaitAndAssert();
|
||||
}
|
||||
|
||||
@Test(expected=MessageDeliveryException.class)
|
||||
public void messageDeliverExceptionIfSystemSessionForwardFails() throws Exception {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
|
||||
this.relay.handleMessage(MessageBuilder.withPayloadAndHeaders("test", headers).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void brokerBecomingUnvailableTriggersErrorFrame() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user