Closed
Description
glodon opened SPR-15282 and commented
when large number of clients reconnected, some client cannot receive data
this problem seems to be caused by class DefaultSubscriptionRegistry,
if connections is more than CacheLimit, when all of them disconnected, updatecache will be cleared, but some destination will be remain in accessCache,
when clients reconnect , if the destination exist in accessCache,destination Info will not be update
so the message will not send sucessfully
// code for this problem
// add destination to cache
public LinkedMultiValueMap<String, String> getSubscriptions(String destination, Message<?> message) {
LinkedMultiValueMap<String, String> result = this.accessCache.get(destination);
// only put when destination not exist in accessCache
if (result == null) {
synchronized (this.updateCache) {
...
if (!result.isEmpty()) {
this.updateCache.put(destination, result.deepCopy());
this.accessCache.put(destination, result);
}
}
}
return result;
}
// clients disconnect
public void updateAfterRemovedSession(SessionSubscriptionInfo info) {
synchronized (this.updateCache) {
Set<String> destinationsToRemove = new HashSet<>();
for (Map.Entry<String, LinkedMultiValueMap<String, String>> entry : this.updateCache.entrySet()) {
// set value for destinationsToRemove
}
for (String destination : destinationsToRemove) {
this.updateCache.remove(destination);
this.accessCache.remove(destination);
}
}
}
Affects: 4.2.9, 4.3.6, 5.0 M5
Issue Links:
- DefaultSubscriptionRegistry should prevent duplicate subscription id in accessCache [SPR-15543] #20102 DefaultSubscriptionRegistry should prevent duplicate subscription id in accessCache
- SimpleBrokerMessageHandler SubscriptionRegistry DestinationCache doesn't honour unique subscriptionId [SPR-15414] #19976 SimpleBrokerMessageHandler SubscriptionRegistry DestinationCache doesn't honour unique subscriptionId