Skip to content

Commit dc066b0

Browse files
committed
"Order of messages" in STOMP section of reference docs
Issue: SPR-13989
1 parent 0c44b52 commit dc066b0

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
@@ -1880,6 +1880,60 @@ of the `message-broker` element in XML.
18801880

18811881

18821882

1883+
[[websocket-stomp-ordered-messages]]
1884+
=== Order of Messages
1885+
1886+
Messages from the broker are published to the "clientOutboundChannel" from where they are
1887+
written to WebSocket sessions. As the channel is backed by a `ThreadPoolExecutor` messages
1888+
are processed in different threads, and the resulting sequence received by the client may
1889+
not match the exact order of publication.
1890+
1891+
If this is an issue, enable the following flag:
1892+
1893+
[source,java,indent=0]
1894+
[subs="verbatim,quotes"]
1895+
----
1896+
@Configuration
1897+
@EnableWebSocketMessageBroker
1898+
public class MyConfig implements WebSocketMessageBrokerConfigurer {
1899+
1900+
@Override
1901+
protected void configureMessageBroker(MessageBrokerRegistry registry) {
1902+
// ...
1903+
registry.setPreservePublishOrder(true);
1904+
}
1905+
1906+
}
1907+
----
1908+
1909+
The same in XML:
1910+
1911+
[source,xml,indent=0]
1912+
[subs="verbatim,quotes,attributes"]
1913+
----
1914+
<beans xmlns="http://www.springframework.org/schema/beans"
1915+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1916+
xmlns:websocket="http://www.springframework.org/schema/websocket"
1917+
xsi:schemaLocation="
1918+
http://www.springframework.org/schema/beans
1919+
http://www.springframework.org/schema/beans/spring-beans.xsd
1920+
http://www.springframework.org/schema/websocket
1921+
http://www.springframework.org/schema/websocket/spring-websocket.xsd">
1922+
1923+
<websocket:message-broker preserve-publish-order="true">
1924+
<!-- ... -->
1925+
</websocket:message-broker>
1926+
1927+
</beans>
1928+
----
1929+
1930+
When the flag is set, messages within the same client session are published to the
1931+
"clientOutboundChannel" one at a time, so that the order of publication is guaranteed.
1932+
Note that this incurs a small performance overhead, so enable it only if required.
1933+
1934+
1935+
1936+
18831937
[[websocket-stomp-appplication-context-events]]
18841938
=== Events and Interception
18851939

0 commit comments

Comments
 (0)