RSocket

Spring WebFlux + React搭建后台管理系统(11):尝试RSocket数据流传输

不问归期 提交于 2020-09-24 08:32:54
reactor等响应式可以轻松的传递流数据,想起了spring的webflux也支持以rsocket,它可以通过websocket或是tcp的方式进行数据传输,正好有java版本和js版本,且spring也支持rsocket,下面尝试是哟给你rsocket模拟天气数据的传输,前端接到数据通过折线图展示。 1. 后端部分 1.1 model实现 创建一个weather类用于传输包装数据 包含时间、风速、风向、温度数据 /** * @author: ffzs * @Date: 2020/9/2 下午5:12 */ @Data @Builder @AllArgsConstructor @NoArgsConstructor public class Weather { Long id ; LocalDateTime date ; Long direction ; Long speed ; Long temperature ; } 1.2 服务实现 使用random获取一些数据用于测试 rsocket的controller使用的是 @Controller 路由是一段字符串 @MessageMapping("weather") /** * @author: ffzs * @Date: 2020/9/2 下午4:35 */ @Controller @Slf4j public class

Spring WebFlux (6): RSocket 服务实现

自闭症网瘾萝莉.ら 提交于 2020-08-14 11:55:25
RSocket官网:https://rsocket.io/ RSocket是一种二进制协议,可用于字节流传输,例如TCP,WebSockets和Aeron。 提供了四中交互模式: request/response (stream of 1) 请求/响应(单响应)大多数请求就是这种模式,仅1个响应的流,是在单个连接上多路复用的异步消息 request/stream (finite stream of many) 可以将其视为“集合”或“列表”响应,但不是将所有数据作为单个响应返回,而是按顺序流回每个元素。 fire-and-forget (no response) 无返回,在不需要响应时非常有用。它不仅可以通过跳过响应来节省网络使用量,而且可以在客户端和服务器处理时间内进行重大的性能优化,因为不需要簿记来等待和关联响应或取消请求。适用于可以有丢失的场景(非关键日子记录) channel (bi-directional streams) 双向消息流,用于源数据更新,断开连接等,可以获取订阅更新后的差额而不是重新获取一遍 它支持会话恢复,以允许跨不同的传输连接恢复长寿命的流。当网络连接频繁断开,切换和重新连接时,这对于移动服务器通信特别有用。 Springboot对RSocket进行了封装 MessagingRSocket ,通过Message进行传递,依赖如下:

How to configure RSocket security in a Spring Boot application with Spring Security

你说的曾经没有我的故事 提交于 2020-07-09 04:16:06
问题 RSocket seems to be a nice alternative to HTTP/S for microservice to microservice communication. Fortunately Spring Boot already has a smooth integration that eases the configuration of it. However I am missing information about everything related to RSocket security, both in RSocket and Spring (Boot, Security) documentation. My questions are: 1) How can we configure RSocket to use TLS (in the context of a Spring Boot application)? 2) Does Spring Security add any additional features to

How to configure RSocket security in a Spring Boot application with Spring Security

大憨熊 提交于 2020-07-09 04:14:11
问题 RSocket seems to be a nice alternative to HTTP/S for microservice to microservice communication. Fortunately Spring Boot already has a smooth integration that eases the configuration of it. However I am missing information about everything related to RSocket security, both in RSocket and Spring (Boot, Security) documentation. My questions are: 1) How can we configure RSocket to use TLS (in the context of a Spring Boot application)? 2) Does Spring Security add any additional features to

Send message only to certain client using websockets with Rsocket and Spring Webflux

孤街浪徒 提交于 2020-05-24 03:28:47
问题 I am trying to use Rsocket with websocket in one of my POC projects. In my case user login is not required. I would like to send a message only to certain clients when I receive a message from another service. Basically, my flow goes like this. Service A Service B |--------| websocket |------------------| Queue based comm |---------------| | Web |----------------->| Rsocket server |--------------------->| Another | | |<-----------------| using Websocket |<---------------------| service | |---

Migrating existing Spring Websocket handler to use rsocket

别说谁变了你拦得住时间么 提交于 2020-04-30 09:28:50
问题 Suppose I have this simple Websocket handler for chat messages: @Override public Mono<Void> handle(WebSocketSession webSocketSession) { webSocketSession .receive() .map(webSocketMessage -> webSocketMessage.getPayloadAsText()) .map(textMessage -> textMessageToGreeting(textMessage)) .doOnNext(greeting-> greetingPublisher.push(greeting)) .subscribe(); final Flux<WebSocketMessage> message = publisher .map(greet -> processGreeting(webSocketSession, greet)); return webSocketSession.send(message); }