stomp

Spring Websocket STOMP: send RECEIPT frames

馋奶兔 提交于 2019-12-10 17:06:49
问题 I have a Websocket-stomp server based on Spring and its SimpleBroker implementation (not utilizing an external broker). I would like to enable STOMP RECEIPT messages. How I could configure my code to send these automatically? 回答1: In Spring Integration test for the STOMP protocol we have this code: //SimpleBrokerMessageHandler doesn't support RECEIPT frame, hence we emulate it this way @Bean public ApplicationListener<SessionSubscribeEvent> webSocketEventListener( final

spring 整合websoket(整理)

大城市里の小女人 提交于 2019-12-10 16:21:17
定义: sockjs.js: 浏览器JavaScript库,它提供了一个类似于网络的对象。SockJS提供了一个连贯的、跨浏览器的Javascript API,它在浏览器和web服务器之间创建了一个低延迟、全双工、跨域通信通道。 STOMP:简单(流)文本定向消息协议,它提供了一个可互操作的连接格式,允许STOMP客户端与任意STOMP消息代理(Broker)进行交互。有点像TCP和HTTP之间的关系,在websocket的通信中,有了STOMP协议后,客户端和服务端能够以更友好的方式进行交流。如果没有提供第三方的STOMP代理,比如Rabbitmq等,那么使用的就是spring容器自己提供的STOMP代理。 关系: 能够使用sock.js建立websocket的客户端连接。websocket可以使用STOMP协议作为传输的协议。 样例代码如下: 定义WebSocketMessageBrokerConfigurer,一般是继承自AbstractWebSocketMessageBrokerConfigurer: @Configuration @EnableWebSocketMessageBroker //在 WebSocket 上启用 STOMP public class WebSocketConfig extends

spring websocket中 STOMP

耗尽温柔 提交于 2019-12-10 16:21:05
26.4 基于WebSocket消息架构STOMP WebSocket协议定义了两种消息类型,文本或字节,但是没定义它们的内容.它有意让客户端和服务端通过通用的子协议(例如,更高水平的协议)来定义消息语法.但是WebSocket协议的使用是可选的,客户端和服务端需要同意某些种类的协议来翻译这些消息. 26.4.1 STOMP概述 STOMP是一个简单的面向文本的消息协议,原来是为Ruby,Python,Perl等脚本语言创建的,用来连接企业消息代理器.设计它的目的是解决一部分通用的消息格式问题.STOMP可以任何可靠的双向流协议中使用,比如TCP或WebSocket.尽管STOMP是一个面向文本的协议,但是消息的内容可以是文本或字节. STOMP 是一个基于Http框架的协议.STOMP框架的结构如下: COMMAND header1:value1 header2:value2 Body^@ 客户端可以使用"SEND"或"SUBSCRIBE"命名来发送或订阅消息,需要一个目的地,用来描述这个消息是什么和谁来接收它.它会激活一个简单的发布订阅机制,可以用来通过代理向其他连接的客户端来发送消息或者向服务端发送消息来要求执行一些工作. 当使用spring的STOMP支持时,spring webSocket应用扮演了客户端的STOMP代理器的角色.消息被路由到

How to add custom headers to STOMP CREATED message in Spring Boot application?

落爺英雄遲暮 提交于 2019-12-10 11:34:57
问题 I'm trying to add custom headers to the STOMP 'CREATED' message, which is received by client at the first connection. Here is the function which connects to the WebSocket using STOMP JavaScript: function connect() { socket = new SockJS('/chat'); stompClient = Stomp.over(socket); stompClient.connect('', '', function(frame) { whoami = frame.headers['user-name']; console.log(frame); stompClient.subscribe('/user/queue/messages', function(message) { console.log("MESSAGE RECEIVED:"); console.log

消息服务-websocket设计

匆匆过客 提交于 2019-12-10 04:10:17
欢迎fork star 本人开源项目 本文介绍的所有代码均再码云中,如果对你有帮助,欢迎点个star支持,谢谢 1. 使用WebSocket而不使用stomp协议 STOMP在WebSocket之上提供了一个基于帧的线路格式(frame-based wire format)层,用来定义消息的语义。 乍看上去,STOMP的消息格式非常类似于HTTP请求的结构。 与HTTP请求和响应类似,STOMP帧由命令、一个或多个头信息以及负载所组成。 使用STOMP的好处在于,它完全就是一种消息队列模式,你可以使用生产者与消费者的思想来认识它,发送消息的是生产者,接收消息的是消费者。 而消费者可以通过订阅不同的destination,来获得不同的推送消息,不需要开发人员去管理这些订阅与推送目的地之前的关系, 2. 第一版是基于WebSocket协议之上的STOMP协议 第一版已经使用了很长时间,其中websocket链接推送这块一直不稳定,有时消耗很大资源,有时链接超时断开,其实都是因为使用了不熟悉的STOMP协议造成的。 STOMP协议当时是考虑不同客户端,可能不支持WebSocket协议,不如IE8,IE9等,会退而求其次使用轮询的方式,即发布订阅的形式依然可以接受到消息。所以引用了此协议,经过一年的测试,发现并不适用,所以,应该使用最原始的WebSocket更好。 3.

how to capture subscribe event in my webSocket server with Spring 4

我的未来我决定 提交于 2019-12-10 01:48:01
问题 I did a simple web socket communication with spring 4, STOMP and sock.js, following this https://spring.io/guides/gs/messaging-stomp-websocket/ Now I want to upgrade it to simple chat. My problem is that when user subscribes to new chat room, he should get past messages. I don't know how to capture the moment when he subscribed to send him the list of the messages. I tried using @MessageMapping annotation, but didn't reach any success: @Controller public class WebSocketController { @Autowired

StompClientLib - unsubscribe socketclient

人盡茶涼 提交于 2019-12-09 19:36:44
问题 I've added StompClientLib in my project and I'm facing problem while unsubscribing a destination topic. Unsubscription of destination gives following error: "org.apache.activemq.transport.stomp.ProtocolException: No subscription matched.\r\tat org.apache.activemq.transport.stomp.ProtocolConverter.onStompUnsubscribe(ProtocolConverter.java:734)\r\tat org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommand(ProtocolConverter.java:262)\r\tat org.apache.activemq.transport.ws

Stomp spring web socket message exceeds size limit

为君一笑 提交于 2019-12-08 23:53:41
问题 I am implementing spring web-socket into our spring mvc web application. However I am running into message over size limits when I am trying to send a really big message to an endpoint. I am getting the following error, message:The 'content-length' header 68718 exceeds the configured message buffer size limit 65536 14:49:11,506 ERROR [org.springframework.web.socket.messaging.StompSubProtocolHandler] (http-localhost/127.0.0.1:8080-4) Failed to parse TextMessage payload=[13684590},..],

Securing a Spring messaging based websocket service

血红的双手。 提交于 2019-12-08 16:49:27
I am working on this for 3 weeks now without a real solution and I really hope you can help me out. A bit project background: Webapp with a JavaScript/PHP based Client sends via SocksJS and Stomp a message to a "gate" The gate is written in Java/Spring and uses @SendTo and @MessageMapping to send and recieve messages The messages from the gate are sent to RabbitMQ and back to the client via "messageBrokerRegistry.enableStompBrokerRelay" So far it works, messages being sent are coming back. Now the advanced SECURITY part: The messages should be secured via cookies containing a user and stuff...

Spring Boot WebSocket: How do I know when a Client has Unsubscribed?

旧时模样 提交于 2019-12-08 12:28:44
问题 I currently have a simple WebSocket with STOMP setup where a client connects to a topic (with an ID). The controller immediately responds with what was asked for, and a variable is set indicating what the client has subscribed to. A method, annotated with @Scheduled , now sends to the client what it has requested every few seconds. The scheduled method does not do anything until the client has connected for the first time. However, after the first subscription it will continue publishing