Skip to content

Commit 14e87d2

Browse files
committed
Add reference to ConcurrentWebSocketSessionDecorator in the docs.
Issue: SPR-12886
1 parent 388ce92 commit 14e87d2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/WebSocketSession.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ public interface WebSocketSession extends Closeable {
120120

121121
/**
122122
* Send a WebSocket message: either {@link TextMessage} or {@link BinaryMessage}.
123+
*
124+
* <p><strong>Note:</strong> The underlying standard WebSocket session (JSR-356) does
125+
* not allow concurrent sending. Therefore sending must be synchronized. To ensure
126+
* that, one option is to wrap the {@code WebSocketSession} with the
127+
* {@link org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator
128+
* ConcurrentWebSocketSessionDecorator}.
129+
* @see org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator
123130
*/
124131
void sendMessage(WebSocketMessage<?> message) throws IOException;
125132

src/docs/asciidoc/web/websocket.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,18 @@ The following example shows the XML configuration equivalent of the preceding ex
102102
----
103103
====
104104

105-
The pereceding example is for use in Spring MVC applications and should be included in the
105+
The preceding example is for use in Spring MVC applications and should be included in the
106106
configuration of a <<mvc-servlet,`DispatcherServlet`>>. However, Spring's WebSocket
107107
support does not depend on Spring MVC. It is relatively simple to integrate a `WebSocketHandler`
108108
into other HTTP-serving environments with the help of
109109
{api-spring-framework}/web/socket/server/support/WebSocketHttpRequestHandler.html[`WebSocketHttpRequestHandler`].
110110

111+
When using the `WebSocketHandler` API directly vs indirectly, e.g. through the
112+
<<websocket-stomp>> messaging, the application must synchronize the sending of messages
113+
since the underlying standard WebSocket session (JSR-356) does not allow concurrent
114+
sending. One option is to wrap the `WebSocketSession` with
115+
{api-spring-framework}/web/socket/handler/ConcurrentWebSocketSessionDecorator.html[`ConcurrentWebSocketSessionDecorator`].
116+
111117

112118

113119
[[websocket-server-handshake]]

0 commit comments

Comments
 (0)