spring-webflux

Missing Content-Length header sending POST request with WebClient (SpringBoot 2.0.2.RELEASE)

六月ゝ 毕业季﹏ 提交于 2020-07-19 06:11:53
问题 I'm using WebClient (SpringBoot 2.0.2.RELEASE) to send a POST with SOAP request, but it is missing " Content-Length " header required by the legacy API. Is it possible to configure WebClient to include " Content-Length " header? There is an Spring Framework Issue resolved and introduced for EncoderHttpMessageWriter in SpringBoot 2.0.1, but it seems not to work for JAXB. I tried to use BodyInserters : webClient.post().body(BodyInserters.fromObject(request)).exchange(); and syncBody : webClient

Webflux repeatWhenEmpty or retryWhen

China☆狼群 提交于 2020-07-10 10:27:27
问题 I use SpringBoot and reactive programming with Webflux. I want to repeat some calling of my endpoint till data will be available (something will be returned). I want to call commandControllerApi.findById until displayCommand will be returned with status == SUCCESS . How to tell Webflux that this part of my chain should be called for example 5 times because the data in my database should apper after 5-10 seconds... I think the current code causes calling the whole chain again and not only the

Repeat a WebClient get with new parameters

社会主义新天地 提交于 2020-07-10 06:15:20
问题 I am developing a Spring WebFlux application and I have a web adapter that I use to call the external api methods that I use. One of the apis has a paginated result using a link header with a rel="next". I need to call this api until this next link does not exist but I am unsure how to achieve this. Below is the basic call that I am currently using: public Flux<ItemDto> getAllItems(){ return webClient.get() //The headers and base url for the api are defined in the constructor .uri("/api/items

Connection pool size with postgres r2dbc-pool

与世无争的帅哥 提交于 2020-07-09 09:35:35
问题 I'm not able to open more than 10 connections with spring-webflux and r2dbc (with r2dbc-pool driver 0.8.0.M8 ). My config looks like: @Configuration public class PostgresConfig extends AbstractR2dbcConfiguration { @Override @Bean public ConnectionFactory connectionFactory() { ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder() .option(DRIVER, "pool") .option(PROTOCOL, "postgresql") .option(HOST, host) .option(USER, user) .option(PASSWORD, password)

Connection pool size with postgres r2dbc-pool

早过忘川 提交于 2020-07-09 09:33:21
问题 I'm not able to open more than 10 connections with spring-webflux and r2dbc (with r2dbc-pool driver 0.8.0.M8 ). My config looks like: @Configuration public class PostgresConfig extends AbstractR2dbcConfiguration { @Override @Bean public ConnectionFactory connectionFactory() { ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder() .option(DRIVER, "pool") .option(PROTOCOL, "postgresql") .option(HOST, host) .option(USER, user) .option(PASSWORD, password)

Spring Web Reactive client

Deadly 提交于 2020-07-05 07:34:29
问题 I'm trying to use the Spring Reactive WebClient to upload a file to a spring controller. The controller is really simple and looks like this: @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity<String> uploadFile( @RequestParam("multipartFile") MultipartFile multipartFile, @RequestParam Map<String, Object> entityRequest ) { entityRequest.entrySet().forEach(System.out::println); System.out.println(multipartFile); return ResponseEntity.ok("OK");

Spring Web Reactive client

风格不统一 提交于 2020-07-05 07:33:08
问题 I'm trying to use the Spring Reactive WebClient to upload a file to a spring controller. The controller is really simple and looks like this: @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity<String> uploadFile( @RequestParam("multipartFile") MultipartFile multipartFile, @RequestParam Map<String, Object> entityRequest ) { entityRequest.entrySet().forEach(System.out::println); System.out.println(multipartFile); return ResponseEntity.ok("OK");

Can you Flux.zip a mono and a flux and and repeat the mono value for every flux value?

风格不统一 提交于 2020-06-28 05:07:09
问题 Is it possible to do something like the code below? I have one service that makes an API call and another one which returns a stream of values. I need to modify every value by the value returned by the API call. return Flux.zip( someMono.get(), someFlux.Get(), (d, t) -> { //HERE D IS ALWAYS THE SAME AND T IS EVERY NEW FLUX VALUE }); I've tried with .repeat() for the Mono and it works, but it's calling the method every time there's a new Flux value and it's a API call, so it's not good. Is it

DataBufferLimitException: Exceeded limit on max bytes to buffer webflux eroor

匆匆过客 提交于 2020-06-27 07:41:05
问题 when i send a file et receive a array of byte i have alway a probleme with webflux to receive the array. the error thrown : org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144 at org.springframework.core.io.buffer.LimitedDataBufferList.raiseLimitException(LimitedDataBufferList.java:101) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException Do you now how to resolve that in webflux ? 回答1: I suppose this issue is about

How to serve files/PDF files the reactive way in spring

人走茶凉 提交于 2020-06-25 03:26:12
问题 I have the following endpoint code to serve PDF files. @RequestMapping ResponseEntity<byte[]> getPDF() { File file = ...; byte[] contents = null; try { try (FileInputStream fis = new FileInputStream(file)) { contents = new byte[(int) file.length()]; fis.read(contents); } } catch(Exception e) { // error handling } HttpHeaders headers = new HttpHeaders(); headers.setContentDispositionFormData(file.getName(), file.getName()); headeres.setCacheControl("must-revalidate, post-check=0, pre-check=0")