Skip to content

Commit 9b2c840

Browse files
committed
"Order of messages" in STOMP section of reference docs
Issue: SPR-13989
1 parent 23c379d commit 9b2c840

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/docs/asciidoc/web/websocket.adoc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,60 @@ of the `message-broker` element in XML.
19151915

19161916

19171917

1918+
[[websocket-stomp-ordered-messages]]
1919+
=== Order of Messages
1920+
1921+
Messages from the broker are published to the "clientOutboundChannel" from where they are
1922+
written to WebSocket sessions. As the channel is backed by a `ThreadPoolExecutor` messages
1923+
are processed in different threads, and the resulting sequence received by the client may
1924+
not match the exact order of publication.
1925+
1926+
If this is an issue, enable the following flag:
1927+
1928+
[source,java,indent=0]
1929+
[subs="verbatim,quotes"]
1930+
----
1931+
@Configuration
1932+
@EnableWebSocketMessageBroker
1933+
public class MyConfig implements WebSocketMessageBrokerConfigurer {
1934+
1935+
@Override
1936+
protected void configureMessageBroker(MessageBrokerRegistry registry) {
1937+
// ...
1938+
registry.setPreservePublishOrder(true);
1939+
}
1940+
1941+
}
1942+
----
1943+
1944+
The same in XML:
1945+
1946+
[source,xml,indent=0]
1947+
[subs="verbatim,quotes,attributes"]
1948+
----
1949+
<beans xmlns="http://www.springframework.org/schema/beans"
1950+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1951+
xmlns:websocket="http://www.springframework.org/schema/websocket"
1952+
xsi:schemaLocation="
1953+
http://www.springframework.org/schema/beans
1954+
http://www.springframework.org/schema/beans/spring-beans.xsd
1955+
http://www.springframework.org/schema/websocket
1956+
http://www.springframework.org/schema/websocket/spring-websocket.xsd">
1957+
1958+
<websocket:message-broker preserve-publish-order="true">
1959+
<!-- ... -->
1960+
</websocket:message-broker>
1961+
1962+
</beans>
1963+
----
1964+
1965+
When the flag is set, messages within the same client session are published to the
1966+
"clientOutboundChannel" one at a time, so that the order of publication is guaranteed.
1967+
Note that this incurs a small performance overhead, so enable it only if required.
1968+
1969+
1970+
1971+
19181972
[[websocket-stomp-appplication-context-events]]
19191973
=== Events and Interception
19201974

0 commit comments

Comments
 (0)