GH-8681: Expose send-buffer-overflow-strategy

Fixes https://github.com/spring-projects/spring-integration/issues/8681

* Expose `send-buffer-overflow-strategy` attribute for WebSocket XML configuration
* GH-8681: Add send-buffer-overflow-strategy to documentation
This commit is contained in:
ColoredCarrot
2023-07-24 17:03:50 +02:00
committed by GitHub
parent f4212d8df4
commit bd013e095c
7 changed files with 111 additions and 47 deletions

View File

@@ -17,6 +17,7 @@
path="/ws"
send-buffer-size-limit="100000"
send-time-limit="100"
send-buffer-overflow-strategy="DROP"
handshake-handler="handshakeHandler"
handshake-interceptors="handshakeInterceptor"
decorator-factories="decoratorFactory"
@@ -66,6 +67,7 @@
uri-variables="ws,user"
send-buffer-size-limit="1000"
send-time-limit="100"
send-buffer-overflow-strategy="DROP"
origin="FOO"
phase="100">
<int-websocket:http-headers>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@ import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.client.WebSocketClient;
import org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator;
import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory;
import org.springframework.web.socket.messaging.StompSubProtocolHandler;
import org.springframework.web.socket.server.HandshakeHandler;
@@ -60,6 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Artem Bilan
* @author Julian Koch
*
* @since 4.1
*/
@@ -155,6 +157,8 @@ public class WebSocketParserTests {
assertThat(interceptors[0]).isSameAs(this.handshakeInterceptor);
assertThat(TestUtils.getPropertyValue(this.serverWebSocketContainer, "sendTimeLimit")).isEqualTo(100);
assertThat(TestUtils.getPropertyValue(this.serverWebSocketContainer, "sendBufferSizeLimit")).isEqualTo(100000);
assertThat(TestUtils.getPropertyValue(this.serverWebSocketContainer, "sendBufferOverflowStrategy"))
.isEqualTo(ConcurrentWebSocketSessionDecorator.OverflowStrategy.DROP);
assertThat(TestUtils.getPropertyValue(this.serverWebSocketContainer, "origins", String[].class))
.isEqualTo(new String[] {"https://foo.com"});
@@ -244,6 +248,8 @@ public class WebSocketParserTests {
.isSameAs(this.customInboundAdapter);
assertThat(TestUtils.getPropertyValue(this.clientWebSocketContainer, "sendTimeLimit")).isEqualTo(100);
assertThat(TestUtils.getPropertyValue(this.clientWebSocketContainer, "sendBufferSizeLimit")).isEqualTo(1000);
assertThat(TestUtils.getPropertyValue(this.clientWebSocketContainer, "sendBufferOverflowStrategy"))
.isEqualTo(ConcurrentWebSocketSessionDecorator.OverflowStrategy.DROP);
assertThat(TestUtils.getPropertyValue(this.clientWebSocketContainer, "connectionManager.uri", URI.class))
.isEqualTo(new URI("ws://foo.bar/ws?service=user"));
assertThat(TestUtils.getPropertyValue(this.clientWebSocketContainer, "connectionManager.client"))
@@ -258,6 +264,8 @@ public class WebSocketParserTests {
.isEqualTo(10 * 1000);
assertThat(TestUtils.getPropertyValue(this.simpleClientWebSocketContainer, "sendBufferSizeLimit"))
.isEqualTo(512 * 1024);
assertThat(TestUtils.getPropertyValue(this.simpleClientWebSocketContainer, "sendBufferOverflowStrategy"))
.isNull();
assertThat(TestUtils.getPropertyValue(this.simpleClientWebSocketContainer, "connectionManager.uri", URI.class))
.isEqualTo(new URI("ws://foo.bar"));
assertThat(TestUtils.getPropertyValue(this.simpleClientWebSocketContainer, "connectionManager.client"))