spring-webflux

Mirror @RequestPart behavior in WebFlux functional router definitions with different content types

与世无争的帅哥 提交于 2020-08-11 18:50:30
问题 Problem We're developing a Spring Boot service to upload data to different back end databases. The idea is that, in one multipart/form-data request a user will send a "model" (basically a file) and "modelMetadata" (which is JSON that defines an object of the same name in our code). We got the below to work in the WebFlux annotated controller syntax, when the user sends the "modelMetadata" in the multipart form with the content-type of "application/json": @PostMapping(consumes = [MediaType

Mirror @RequestPart behavior in WebFlux functional router definitions with different content types

有些话、适合烂在心里 提交于 2020-08-11 18:47:44
问题 Problem We're developing a Spring Boot service to upload data to different back end databases. The idea is that, in one multipart/form-data request a user will send a "model" (basically a file) and "modelMetadata" (which is JSON that defines an object of the same name in our code). We got the below to work in the WebFlux annotated controller syntax, when the user sends the "modelMetadata" in the multipart form with the content-type of "application/json": @PostMapping(consumes = [MediaType

404 error with swagger-ui and spring webflux

有些话、适合烂在心里 提交于 2020-08-10 22:09:26
问题 I am developping REST services with Spring Webflux and I want to produce documentation with Swagger2 for my API with. I discovered that Webflux is only supported with Swagger2 version 3.0.0 snapshot. Here's my configuration : java 11 maven 3 My SwaggerConfiguration bean looks like this import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders

How to implement @RequestPart in a reactive, functional (not annotated) webflux service?

别说谁变了你拦得住时间么 提交于 2020-08-09 08:15:17
问题 I have a Spring Boot 2, reactive webflux web service, which persists uploaded, multipart fileparts to MongoDB's GridFS. This is working properly. Today, a request was made to include metadata for the files being added to GridFS. Unfortunately, I have not been able to get it to work with my functional/non-annotated web service. I would appreciate any suggestions or nudges in the correct direction. Here are the details: An example of the request being sent to my endpoint: curl -X "POST" "http:/

Reactive Programming: Spring WebFlux: How to build a chain of micro-service calls?

对着背影说爱祢 提交于 2020-08-05 10:23:11
问题 Spring Boot Application: a @RestController receives the following payload: { "cartoon": "The Little Mermaid", "characterNames": ["Ariel", "Prince Eric", "Sebastian", "Flounder"] } I need to process it in the following way: Get the unique Id for each character name: make an HTTP call to "cartoon-characters" microservice, that returns ids by names Transform data received by the controller: replace character names with appropriate ids that were received on the previous step from "cartoon

Execute blocking JDBC call in Spring Webflux

假装没事ソ 提交于 2020-08-04 05:13:58
问题 I am using Spring Webflux with Spring data jpa using PostgreSql as backend db. I don't want to block the main thread while making db calls like find and save . To achieve the same, I have a main scheduler in Controller class and a jdbcScheduler service classes. The way I have defined them is: @Configuration @EnableJpaAuditing public class CommonConfig { @Value("${spring.datasource.hikari.maximum-pool-size}") int connectionPoolSize; @Bean public Scheduler scheduler() { return Schedulers

Spring WebClient: How to stream large byte[] to file?

时光毁灭记忆、已成空白 提交于 2020-07-31 12:13:49
问题 It seems like it the Spring RestTemplate isn't able to stream a response directly to file without buffering it all in memory. What is the proper to achieve this using the newer Spring 5 WebClient ? WebClient client = WebClient.create("https://example.com"); client.get().uri(".../{name}", name).accept(MediaType.APPLICATION_OCTET_STREAM) ....? I see people have found a few workarounds/hacks to this issue with RestTemplate , but I am more interested in doing it the proper way with the WebClient

Spring WebClient: How to stream large byte[] to file?

人盡茶涼 提交于 2020-07-31 12:13:28
问题 It seems like it the Spring RestTemplate isn't able to stream a response directly to file without buffering it all in memory. What is the proper to achieve this using the newer Spring 5 WebClient ? WebClient client = WebClient.create("https://example.com"); client.get().uri(".../{name}", name).accept(MediaType.APPLICATION_OCTET_STREAM) ....? I see people have found a few workarounds/hacks to this issue with RestTemplate , but I am more interested in doing it the proper way with the WebClient

Spring WebClient: How to stream large byte[] to file?

放肆的年华 提交于 2020-07-31 12:13:00
问题 It seems like it the Spring RestTemplate isn't able to stream a response directly to file without buffering it all in memory. What is the proper to achieve this using the newer Spring 5 WebClient ? WebClient client = WebClient.create("https://example.com"); client.get().uri(".../{name}", name).accept(MediaType.APPLICATION_OCTET_STREAM) ....? I see people have found a few workarounds/hacks to this issue with RestTemplate , but I am more interested in doing it the proper way with the WebClient

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

…衆ロ難τιáo~ 提交于 2020-07-19 06:12:15
问题 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