You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before this change, when a client subscribed to a "user" destination
(e.g. /user/foo), actual messages received in response to that
subscription contained the server-translated, unique user destination
(e.g. /foo-user123).
This is not an issue for clients such as stomp.js since the
subscription is unique and sufficient to match subscription responses.
However, other STOMP clients do additional checks on the destination
of the subscription and the response.
This change ensures that messages sent to clients on user destionations
always contain a destination that matches the one on the original
subscription.
Issue: SPR-11423
Copy file name to clipboardExpand all lines: spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java
+69-34Lines changed: 69 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -30,10 +30,21 @@
30
30
importjava.util.Set;
31
31
32
32
/**
33
-
* A default implementation of {@link UserDestinationResolver}.
33
+
* A default implementation of {@link UserDestinationResolver} that relies
34
+
* on the {@link org.springframework.messaging.simp.user.UserSessionRegistry}
35
+
* provided to the constructor to find the sessionIds associated with a user
36
+
* and then uses the sessionId to make the target destination unique.
34
37
* <p>
35
-
* Uses the {@link org.springframework.messaging.simp.user.UserSessionRegistry}
36
-
* provided to the constructor to find the sessionIds associated with a user.
38
+
* When a user attempts to subscribe to "/user/queue/position-updates", the
39
+
* "/user" prefix is removed and a unique suffix added, resulting in something
40
+
* like "/queue/position-updates-useri9oqdfzo" where the suffix is based on the
41
+
* user's session and ensures it does not collide with any other users attempting
42
+
* to subscribe to "/user/queue/position-updates".
43
+
* <p>
44
+
* When a message is sent to a user with a destination such as
45
+
* "/user/{username}/queue/position-updates", the "/user/{username}" prefix is
46
+
* removed and the suffix added, resulting in something like
47
+
* "/queue/position-updates-useri9oqdfzo".
37
48
*
38
49
* @author Rossen Stoyanchev
39
50
* @since 4.0
@@ -87,30 +98,32 @@ public UserSessionRegistry getUserSessionRegistry() {
0 commit comments