Skip to content

WebSocket configuration doesn't work properly with the buffer size limitation #25581

@OleksiiKlochko

Description

@OleksiiKlochko

Affects: 5.2.8.RELEASE


@Configuration
@EnableWebSocketMessageBroker
public class MyConfig implements WebSocketMessageBrokerConfigurer {

	@Override
	public void configureMessageBroker(MessageBrokerRegistry registry) {
		// ...
		registry.setPreservePublishOrder(true);
	}

	@Override
	public void configureWebSocketTransport(WebSocketTransportRegistration registry) {
		registry.setSendBufferSizeLimit(512 * 1024);
	}
}

The setSendBufferSizeLimit method has no more effect after setPreservePublishOrder(true).

The reason is that the instance of OrderedMessageSender keeps all messages and sends only one message at a time to the buffer.

Thus, the application can slow down significantly or even crash with OutOfMemory Error instead of just closing the WebSocket connection when the messages queue overflow.

Memory Analyzer shows how OrderedMessageSender can occupy the whole heap:
Heap

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions