当前位置 : 首页 » 文章分类 :  开发  »  Spring-WebFlux

Spring-WebFlux

Spring-WebFlux 相关笔记

Reactive Streams、Reactor 和 Web Flux关系

Reactive Streams 是规范
Reactor 实现了 Reactive Streams
Web Flux 以 Reactor 为基础,实现 Web 领域的反应式编程框架。

使用 Spring 5 的 WebFlux 开发反应式 Web 应用
https://www.ibm.com/developerworks/cn/java/spring5-webflux-reactive/index.html

Spring Reactor 入门与实践
https://www.jianshu.com/p/7ee89f70dfe5


WebClient

block()/blockFirst()/blockLast() are blocking, which is not supported in thread

WebClient.post 发送 HTTP 请求报错:

  1. java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-kqueue-3
  2. at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83)
  3. Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
  4. Error has been observed at the following site(s):
  5. |_ checkpoint org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
  6. |_ checkpoint org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
  7. |_ checkpoint HTTP POST "/actuator/route/taskAgent" [ExceptionHandlingWebHandler]
  8. Stack trace:
  9. at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83)
  10. at reactor.core.publisher.Mono.block(Mono.java:1703)
  11. 有时候报错的是 epoll 线程
  12. java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-epoll-142

原因:
包了两层 mono,block 出错
去掉 block


上一篇 Spring-Cloud-Config

下一篇 Reactor

阅读
评论
235
阅读预计1分钟
创建日期 2019-07-03
修改日期 2019-07-03
类别

页面信息

location:
protocol: http:
host: devgou.com
hostname: devgou.com
origin: http://devgou.com
pathname: /article/Spring-WebFlux/
href: http://devgou.com/article/Spring-WebFlux/
document:
referrer:
navigator:
platform: Linux x86_64
userAgent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

评论