Java资源分享网 - 专业的Java学习网站 学Java,上Java资源分享网
Java reactive programming - Reactor 3 and Spring WebFlux PDF 下载
匿名网友发布于:2024-07-19 11:41:03
(侵权举报)
(假如点击没反应,多刷新两次就OK!)

Java reactive programming - Reactor 3 and Spring WebFlux PDF 下载 图1

 

 

资料内容:

 

响应式编程是⼀种⾮阻塞异步编程
import reactor.ipc.netty.tcp.TcpServer;
import reactor.ipc.netty.tcp.TcpClient;
CountDownLatch latch = new CountDownLatch(10);
TcpServer server = TcpServer.create(port);
TcpClient client = TcpClient.create("localhost", port);
final JsonCodec<Pojo, Pojo> codec = new JsonCodec<Pojo, Pojo>(Pojo.class);
server.start(input -> input.send(input.decode(codec).log("serve").map(codec), 5)).await();
client.start(input -> {
input.take(10).decode(codec).log("receive").subscribe(data -> latch.countDown());
input.send(Flux.range(1, 10).map( it -> new Pojo("test" + it)).log(“send").map(codec))
.subscribe();
return Mono.never();
}).await();
latch.await(10, TimeUnit.SECONDS);
client.shutdown().await();
server.shutdown().await();