From a3655c48581dd3977de02f13dd3a7ecc3dcde6c2 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 7 Sep 2021 16:33:31 +0100 Subject: [PATCH] Add tip related to user destinations in STOMP See gh-26986 --- src/docs/asciidoc/web/websocket.adoc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/docs/asciidoc/web/websocket.adoc b/src/docs/asciidoc/web/websocket.adoc index 080a75e0ab..07751ff573 100644 --- a/src/docs/asciidoc/web/websocket.adoc +++ b/src/docs/asciidoc/web/websocket.adoc @@ -1818,12 +1818,16 @@ its own implementation of `WebSocketMessageBrokerConfigurer` that is marked with An application can send messages that target a specific user, and Spring's STOMP support recognizes destinations prefixed with `/user/` for this purpose. For example, a client might subscribe to the `/user/queue/position-updates` destination. -This destination is handled by the `UserDestinationMessageHandler` and -transformed into a destination unique to the user session -(such as `/queue/position-updates-user123`). This provides the convenience of subscribing -to a generically named destination while, at the same time, ensuring no collisions -with other users who subscribe to the same destination so that each user can receive -unique stock position updates. +`UserDestinationMessageHandler` handles this destination and transforms it into a +destination unique to the user session (such as `/queue/position-updates-user123`). +This provides the convenience of subscribing to a generically named destination while, +at the same time, ensuring no collisions with other users who subscribe to the same +destination so that each user can receive unique stock position updates. + +TIP: When working with user destinations, it is important to configure broker and +application destination prefixes as shown in <>, or otherwise the +broker would handle "/user" prefixed messages that should only be handled by +`UserDestinationMessageHandler`. On the sending side, messages can be sent to a destination such as pass:q[`/user/{username}/queue/position-updates`], which in turn is translated