diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java index 305db97bab7..75f4146bb0e 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java @@ -30,11 +30,9 @@ import java.util.Set; /** * A default implementation of {@link UserDestinationResolver}. - * - *
Resolves messages sent to destination patterns "/user/{user-name}/**" as well as - * subscriptions to destinations "/user/queue/**" where the "/user/" prefix used to - * recognize such destinations is customizable via - * {@link #setUserDestinationPrefix(String)}. + *
+ * Uses the {@link org.springframework.messaging.simp.user.UserSessionRegistry}
+ * provided to the constructor to find the sessionIds associated with a user.
*
* @author Rossen Stoyanchev
* @since 4.0
@@ -111,26 +109,26 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
String targetUser;
String targetDestination;
- Set For example when a user attempts to subscribe to "/user/queue/position-updates",
- * the destination may be resolved to "/queue/position-updates-useri9oqdfzo" yielding a
- * unique queue name that does not collide with any other user attempting to do the same.
- * Subsequently when messages are sent to "/user/{username}/queue/position-updates",
- * the destination is translated to "/queue/position-updates-useri9oqdfzo".
+ *
+ * When a user attempts to subscribe to "/user/queue/position-updates", the
+ * "/user" prefix is removed and a unique suffix added, resulting in something
+ * like "/queue/position-updates-useri9oqdfzo" where the suffix is based on the
+ * user's session and ensures it does not collide with any other users attempting
+ * to subscribe to "/user/queue/position-updates".
+ *
+ * When a message is sent to a user with a destination such as
+ * "/user/{username}/queue/position-updates", the "/user/{username}" prefix is
+ * removed and the suffix added, resulting in something like
+ * "/queue/position-updates-useri9oqdfzo".
*
* @author Rossen Stoyanchev
* @since 4.0
@@ -39,12 +44,14 @@ import java.util.Set;
public interface UserDestinationResolver {
/**
- * Resolve the destination of the message to one or more user/session-specific target
- * destinations. If the user has multiple sessions, the method may return more than
- * one target destinations.
+ * Resolve the destination of the message to a set of actual target destinations
+ * to use. If the message is SUBSCRIBE/UNSUBSCRIBE, the returned set will contain
+ * only target destination. If the message represents data being sent to a user,
+ * the returned set may contain multiple target destinations, one for each active
+ * session of the target user.
+ *
* @param message the message to resolve
- * @return the resolved unique user destinations or an empty Set if the message
- * destination is not recognized as a user destination
+ * @return the resolved unique user destination(s) or an empty Set
*/
Set