Is it possible to send binary data with STOMP over WebSockets using Spring-WebSockets?

后端 未结 2 911
失恋的感觉
失恋的感觉 2020-12-15 10:07

I am able to send and receive JSON with STOMP over WebSockets following spring documentation. However performance is poor at large high rates, so I wish to profile the use o

2条回答
  •  庸人自扰
    2020-12-15 10:46

    It seems that org.springframework.web.socket.TextMessage is always used within org.springframework.web.socket.messaging.StompSubProtocolHandler rather than org.springframework.web.socket.BinaryMessage. I've raised a feature request for this SPR-12301 which has been accepted.

    message = MessageBuilder.withPayload(message.getPayload()).setHeaders(headers).build();
    byte[] bytes = this.stompEncoder.encode((Message) message);
    
    synchronized(session) {
        session.sendMessage(new TextMessage(new String(bytes, UTF8_CHARSET)));
    }
    

    Update

    • SPR-12301 was delivered in 4.1.2 but only adds support for receiving binary messages
    • Raised SPR-12475 for sending of binary messages

提交回复
热议问题