spring-webflux

Spring RequestContextHolder and WebTestClient

我的未来我决定 提交于 2020-12-04 09:18:40
问题 I'm using Spring RequestContextHolder in the controller and it works fine. But in the unit test I get java.lang.IllegalStateException using WebTestClient . Here is an example: package demo.reactive.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.RequestContextHolder; import reactor.core.publisher.Mono;

Spring RequestContextHolder and WebTestClient

[亡魂溺海] 提交于 2020-12-04 09:18:23
问题 I'm using Spring RequestContextHolder in the controller and it works fine. But in the unit test I get java.lang.IllegalStateException using WebTestClient . Here is an example: package demo.reactive.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.RequestContextHolder; import reactor.core.publisher.Mono;

WebClient doesn't read response until request write is completed.

不羁岁月 提交于 2020-12-04 00:41:00
问题 I'm trying to implement streaming proxy. I faced with the issue with WebClient from spring reactive. Could anyone help me to understand Do I some wrong way or it's just a bug from WebClient side? Stack: reactor-netty 0.7.8.RELEASE spring-boot 2.0.4.RELEASE Desc: I want to proxy a long stream to external service and then forward stream of responses to the requester. Streaming is happening using chunks (HTTP 1.1 Transfer-Encoding : chunked). External service processes every chunk and sends to

WebClient doesn't read response until request write is completed.

扶醉桌前 提交于 2020-12-04 00:40:24
问题 I'm trying to implement streaming proxy. I faced with the issue with WebClient from spring reactive. Could anyone help me to understand Do I some wrong way or it's just a bug from WebClient side? Stack: reactor-netty 0.7.8.RELEASE spring-boot 2.0.4.RELEASE Desc: I want to proxy a long stream to external service and then forward stream of responses to the requester. Streaming is happening using chunks (HTTP 1.1 Transfer-Encoding : chunked). External service processes every chunk and sends to

WebClient doesn't read response until request write is completed.

安稳与你 提交于 2020-12-04 00:38:21
问题 I'm trying to implement streaming proxy. I faced with the issue with WebClient from spring reactive. Could anyone help me to understand Do I some wrong way or it's just a bug from WebClient side? Stack: reactor-netty 0.7.8.RELEASE spring-boot 2.0.4.RELEASE Desc: I want to proxy a long stream to external service and then forward stream of responses to the requester. Streaming is happening using chunks (HTTP 1.1 Transfer-Encoding : chunked). External service processes every chunk and sends to

WebClient doesn't read response until request write is completed.

蓝咒 提交于 2020-12-04 00:38:17
问题 I'm trying to implement streaming proxy. I faced with the issue with WebClient from spring reactive. Could anyone help me to understand Do I some wrong way or it's just a bug from WebClient side? Stack: reactor-netty 0.7.8.RELEASE spring-boot 2.0.4.RELEASE Desc: I want to proxy a long stream to external service and then forward stream of responses to the requester. Streaming is happening using chunks (HTTP 1.1 Transfer-Encoding : chunked). External service processes every chunk and sends to

WebClient doesn't read response until request write is completed.

江枫思渺然 提交于 2020-12-04 00:38:02
问题 I'm trying to implement streaming proxy. I faced with the issue with WebClient from spring reactive. Could anyone help me to understand Do I some wrong way or it's just a bug from WebClient side? Stack: reactor-netty 0.7.8.RELEASE spring-boot 2.0.4.RELEASE Desc: I want to proxy a long stream to external service and then forward stream of responses to the requester. Streaming is happening using chunks (HTTP 1.1 Transfer-Encoding : chunked). External service processes every chunk and sends to

Webflux upload large files cause Java heap space

夙愿已清 提交于 2020-12-01 21:51:32
问题 Probably not many developers are facing the problem the same as me. But I want to share the solution which I had been solved for almost 1 month. I use Kubernetes and docker-compose, this Webflux service (container) is set the memory limit 1g mem_limit: 1g I am not allowed to increase the memory limit. coRouter has been used as a controller which is in the container. @Configuration class WebController( ) { @Bean fun endpoints() = coRouter { contentType(MediaType.MULTIPART_FORM_DATA).nest {

How to calculate the average of a Project Reactor Flux?

早过忘川 提交于 2020-11-30 00:11:45
问题 I have a method that returns a Flux<SensorData> , let's suppose SensorData has a field measure: Integer . I would like to calculate the average value of measure of the whole Flux. How can it be done? val sensorFlux: Flux<SensorData> = sensorRepository.findAll() ... 回答1: Mono<Double> average = sensorFlux.collect(Collectors.averagingInt(SensorData::getMeasure)) 回答2: Another way of doing it with an auxiliary object: val average = sensorFlux.map { it.measure } .map { Measure(1, it) } .reduce { t: