webflux 中的 DefaultMultipartMessageReader 与 SynchronossPartHttpMessageReader [英] DefaultMultipartMessageReader vs SynchronossPartHttpMessageReader in webflux
问题描述
在 webflux 中,我们有两种不同的实现来读取多部分请求体
In webflux, we have two different implementations for reading multipart request body
DefaultMultipartMessageReader
&SynchronossPartHttpMessageReader
我看到他们写的时候都用nio.由于我使用的是 netty(通过 reactor netty),即使从请求正文中读取也可以使用 nio
I see that both of them uses nio when writing. Since I am using netty (thru reactor netty), even reading from request body would be done using nio
如果是这样,他们每个人的目的是什么?
If so, what is the purpose each of them serve?
推荐答案
从 Spring Framework 5.2 开始,Spring WebFlux 确实附带了 2 个多部分阅读器实现.
As of Spring Framework 5.2, Spring WebFlux indeed ships with 2 multipart reader implementations.
在 Spring Framework 5.0 中,多部分读取器实现依赖于第 3 方库(同步)以非阻塞方式读取多部分请求.但是这种实现不是完全反应式的,可以缓冲数据并将其作为临时文件写入磁盘.
In Spring Framework 5.0, the multipart reader implementation was relying on a 3rd party library (synchronoss) to read multipart requests in a non-blocking fashion. But this implemnetation is not fully reactive and can buffer data and write it to disk as a temporary file.
从 spring-framework#21659 开始,一个新的完全-reactive 实现已经被引入并且是新的默认实现.对于开发者来说,第一个实现仍然是一个可能的选择.
As of spring-framework#21659, a new fully-reactive implementation has been introduced and is the new default. The first implementation remains as a possible choice for developers.
这篇关于webflux 中的 DefaultMultipartMessageReader 与 SynchronossPartHttpMessageReader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!