diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java index 92694f8d9a..501f8c9f39 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java @@ -292,8 +292,11 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { String cachedDestination = entry.getKey(); if (getPathMatcher().match(destination, cachedDestination)) { LinkedMultiValueMap subs = entry.getValue(); - subs.add(sessionId, subsId); - this.accessCache.put(cachedDestination, subs.deepCopy()); + // Subscription id's may also be populated via getSubscriptions() + if (!subs.containsKey(sessionId) || !subs.get(sessionId).contains(subsId)) { + subs.add(sessionId, subsId); + this.accessCache.put(cachedDestination, subs.deepCopy()); + } } } }