Skip to content

STOMP client support [SPR-11588] #16212

@spring-projects-issues

Description

@spring-projects-issues

Iyad Elian opened SPR-11588 and commented

so I am trying to send a STOMP message over WebSockets using Spring and I am having problems with the code. I followed the samples and it suggests a StompMessageHandler which has a StompSession. What is that? I understand a WebSocketSession and over that I encode a StompMessage. So I do something like this instead:
WebSocketSession session = stompClient.connect(handler);
session.sendMessage(new StompMessage(StompCommand.SEND, "topic/test", "Hi"));

My StompMessage extends WebSocketMessage<String> but I can't just use that because AbstractWebSocketSessions.sendMessage checks on the types of the WebSocketMessage and it does not support a StompMessage. I can't extend TextMessage because it is final so I wrap a StompMessage with a TextMessage
session.sendMessage(new TextMessage( new StompMessage(StompCommand.SEND, "topic/test", "Hi").getBytes()));

But I get session closed because AbstractWebSocketSession says
public final void sendMessage(WebSocketMessage<?> message) throws IOException {
Assert.isTrue(isOpen(), "Cannot send message after connection closed.");

STOMP is a text protocol the js guys have couple of lines stomp.js that encodes your message and send it over websocket. Why the java mess.


Affects: 4.0.3

Sub-tasks:

Issue Links:

Referenced from: commits d30b3ea

6 votes, 11 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions