小编Mil*_*nda的帖子

Spring Boot 2.0.2中的WebFlux并发模型

从Spring-Boot 2.0.1升级到2.0.2后,我注意到请求处理线程名称已更改。而且,看起来现在有更多专用于HTTP请求处理的线程。经过一番实验之后,我可以看到在四核服务器上,我们现在拥有:

  • react-http-server-epoll- *-4个线程处理传入的HTTP请求。
  • reactr-http-client-epoll- *-4个线程处理来自WebCLient的响应
  • react-http-nio- *-4个空闲线程

借助于Spring 2.0.1引导我记得只有4历时负责处理传入的请求和Web客户反应的反应器-HTTP-nio- *线程- https://docs.spring.io/spring/docs/5.0.6.RELEASE /spring-framework-reference/web-reactive.html#webflux-concurrency-model

  • 我的发现有效吗?
  • 发生这种变化的原因是什么?
  • 现在Reactor-http-nio- *线程的工作是什么?

spring spring-boot project-reactor spring-webflux

5
推荐指数
0
解决办法
545
查看次数

创建自定义ErrorWebExceptionHandler失败

我试图ErrorWebExceptionHandler通过扩展默认启动项在Spring Boot 2中创建自己的启动项,但是我的应用程序无法以以下消息启动:

Caused by: java.lang.IllegalArgumentException: Property 'messageWriters' is required
at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.afterPropertiesSet(AbstractErrorWebExceptionHandler.java:214) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE]
Run Code Online (Sandbox Code Playgroud)

我的处理程序(科特琳代码):

@Component
@Order(-2)
class SampleErrorWebExceptionHandler(
    errorAttributes: ErrorAttributes?,
    resourceProperties: ResourceProperties?,
    errorProperties: ErrorProperties?,
    applicationContext: ApplicationContext?
) : DefaultErrorWebExceptionHandler(errorAttributes, resourceProperties, errorProperties, applicationContext) {

    override fun logError(request: ServerRequest, errorStatus: HttpStatus) {
        // do something
    }
}
Run Code Online (Sandbox Code Playgroud)

可能是什么原因?

spring-boot spring-webflux

5
推荐指数
2
解决办法
1225
查看次数