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:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2019 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* the {@code <websocket:client-container/>} element.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Julian Koch
|
||||
* @since 4.1
|
||||
*/
|
||||
public class ClientWebSocketContainerParser extends AbstractSingleBeanDefinitionParser {
|
||||
@@ -55,6 +56,7 @@ public class ClientWebSocketContainerParser extends AbstractSingleBeanDefinition
|
||||
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-buffer-size-limit");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-time-limit");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-buffer-overflow-strategy");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "origin");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, IntegrationNamespaceUtils.AUTO_STARTUP);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, IntegrationNamespaceUtils.PHASE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2019 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.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* the {@code <websocket:server-container/>} element.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Julian Koch
|
||||
* @since 4.1
|
||||
*/
|
||||
public class ServerWebSocketContainerParser extends AbstractSingleBeanDefinitionParser {
|
||||
@@ -104,6 +105,7 @@ public class ServerWebSocketContainerParser extends AbstractSingleBeanDefinition
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "handshake-handler");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-buffer-size-limit");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-time-limit");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-buffer-overflow-strategy");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "allowed-origins");
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,20 @@
|
||||
<xsd:union memberTypes="xsd:int xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="send-buffer-overflow-strategy">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The WebSocket session's outbound message buffer overflow strategy.
|
||||
|
||||
Concurrently generated outbound messages are buffered if sending is slow.
|
||||
This strategy determines the behavior when the buffer has reached the limit
|
||||
configured with <send-buffer-size-limit>.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="overflowStrategyEnumeration xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attributeGroup ref="integration:smartLifeCycleAttributeGroup"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
@@ -320,6 +334,20 @@
|
||||
<xsd:union memberTypes="xsd:int xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="send-buffer-overflow-strategy">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The WebSocket session's outbound message buffer overflow strategy.
|
||||
|
||||
Concurrently generated outbound messages are buffered if sending is slow.
|
||||
This strategy determines the behavior when the buffer has reached the limit
|
||||
configured with <send-buffer-size-limit>.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="overflowStrategyEnumeration xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="allowed-origins" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
@@ -505,4 +533,11 @@
|
||||
<xsd:attributeGroup ref="integration:channelAdapterAttributes"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:simpleType name="overflowStrategyEnumeration">
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="TERMINATE"/>
|
||||
<xsd:enumeration value="DROP"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
</xsd:schema>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user