Skip to content

Cannot receive message sometimes with SimpleBrokerMessageHandler [SPR-15282] #19848

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions