spring-webclient

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

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

Access HTTPS RESTful service using Web Client in Spring Boot 2.0 throwing exception

…衆ロ難τιáo~ 提交于 2020-05-09 06:16:32
问题 I have to access one https rest web service(https://example.com) for which certificate has been provided by the client which contains 2 .cer files. I have created keystore.jks and truststore.jks files and imported the .cer files to jks file . by using the below command keytool -genkeypair -alias abcd -keyalg RSA -sigalg garegar -keysize 2048 -storetype jks -keystore keystore.jks -validity 365 -storepass changeit keytool -import -alias abcd -trustcacerts -file free/ca_bundle.cer -keystore

Spring WebClient: Retry with WebFlux.fn + reactor-addons

点点圈 提交于 2020-04-18 03:49:23
问题 I'm trying to add a conditional Retry for WebClient with Kotlin Coroutines + WebFlux.fn + reactor-addons: suspend fun ClientResponse.asResponse(): ServerResponse = status(statusCode()) .headers { headerConsumer -> headerConsumer.addAll(headers().asHttpHeaders()) } .body(bodyToMono(DataBuffer::class.java), DataBuffer::class.java) .retryWhen { Retry.onlyIf { ctx: RetryContext<Throwable> -> (ctx.exception() as? WebClientResponseException)?.statusCode in retryableErrorCodes } .exponentialBackoff

Spring WebClient: Retry with WebFlux.fn + reactor-addons

允我心安 提交于 2020-04-18 03:49:07
问题 I'm trying to add a conditional Retry for WebClient with Kotlin Coroutines + WebFlux.fn + reactor-addons: suspend fun ClientResponse.asResponse(): ServerResponse = status(statusCode()) .headers { headerConsumer -> headerConsumer.addAll(headers().asHttpHeaders()) } .body(bodyToMono(DataBuffer::class.java), DataBuffer::class.java) .retryWhen { Retry.onlyIf { ctx: RetryContext<Throwable> -> (ctx.exception() as? WebClientResponseException)?.statusCode in retryableErrorCodes } .exponentialBackoff

Spring Security 5.2.1 + spring-security-oauth2 + WebClient: how to use password grant-type

末鹿安然 提交于 2020-01-24 00:32:09
问题 Here is my current setup: I'm exposing a WebClient bean with oauth2 filter: @Configuration class OAuthConfiguration { @Bean("authProvider") fun webClient( clientRegistrationRepository: ClientRegistrationRepository, authorizedClientRepository: OAuth2AuthorizedClientRepository, clientHttpConnector: ClientHttpConnector ): WebClient { val oauth = ServletOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrationRepository, authorizedClientRepository) oauth.setDefaultClientRegistrationId(

WebClient maxConnection pool limit?

你。 提交于 2020-01-02 17:33:17
问题 How many concurrent requests can I send if the remote service if blocking? Means: what is the maxConnection pool limit that spring uses internally when using WebClient ? @Autowired private WebClient webClient; webClient.post().uri(url).syncBody(req).retrieve().bodyToMono(type); And moreover: how can I modify it? 回答1: Before reactor-netty 0.9.0.M4 version there wasn't limit by default because of "elastic" connection provider was used. This fix changed it to "fixed" connection provider with the

WebClient maxConnection pool limit?

给你一囗甜甜゛ 提交于 2020-01-02 17:30:05
问题 How many concurrent requests can I send if the remote service if blocking? Means: what is the maxConnection pool limit that spring uses internally when using WebClient ? @Autowired private WebClient webClient; webClient.post().uri(url).syncBody(req).retrieve().bodyToMono(type); And moreover: how can I modify it? 回答1: Before reactor-netty 0.9.0.M4 version there wasn't limit by default because of "elastic" connection provider was used. This fix changed it to "fixed" connection provider with the