-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
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:
- [doc] Update reference for STOMP client [SPR-12814] #17411 [doc] Update reference for STOMP client
Issue Links:
- INT-3685 Add Stomp Client Support ("is depended on by")
- Add SockJS client support [SPR-10797] #15423 Add SockJS client support
Referenced from: commits d30b3ea
6 votes, 11 watchers