spring-webflux

Spring webflux error handler: How to get the reactor context of the request in the error handler?

≯℡__Kan透↙ 提交于 2020-01-04 02:39:09
问题 Spring boot 2.1.5 Project Reactor 3.2.9 In my webflux project, I extensively use the reactor contexts in order to pass around some values. My purpose here is to be able to get the context inside of the Exception handler. A simple example: @Component @Order(-2) public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { public GlobalErrorWebExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties, ApplicationContext applicationContext,

Spring Security Reactive WebFilterChainProxy only calling a single filter chain

穿精又带淫゛_ 提交于 2020-01-04 02:03:25
问题 I need to add security into a Webflux based app and have requirements that mean I need to add multiple filter chains. However, the current implementation of WebFilterChainProxy uses Flux.filterWhen(...) which, if I'm reading the docs correctly, will only ever return the first match in the chain. Given the above I have three questions:- My react knowledge is very limited, can someone confirm if my understanding of what filterWhen does is correct? If so, can anyone suggest a way to get multiple

How to configure in Spring Boot 2 (w/ WebFlux) two ports for HTTP and HTTPS?

不问归期 提交于 2020-01-03 15:33:23
问题 Can anybody tell me how 2 ports (for HTTP and HTTPS) can be configured when using Spring Boot 2 and WebFlux? Any hint is appreciated! 回答1: This isn't directly supported by Spring Boot 2 yet. But, you may be able to get it to work in a couple of ways. By default, Spring Boot WebFlux uses Netty. If you are already configured for ssl, then Spring Boot will start up and open port 8443 (or whatever you have configured). Then, to add 8080, you can do: @Autowired HttpHandler httpHandler; WebServer

How could we use @ExceptionHandler with spring web flux?

拥有回忆 提交于 2020-01-03 13:09:31
问题 In spring web we could use annotation @ExceptionHandler for handling server and client errors for controllers. I've tried to use this annotation with web-flux controller and it still worked for me, but after some investigation I've found out here The situation with Spring Web Reactive is more complicated. Because the reactive streams are evaluted by a different thread than the one that executes the controllers method, the exceptions won’t be propagated to the controller thread automatically.

How to extract response header & status code from Spring 5 WebClient ClientResponse

一曲冷凌霜 提交于 2020-01-03 11:33:23
问题 I am new to Spring Reactive framework & trying to convert Springboot 1.5.x code into Springboot 2.0. I need to return response header after some filtering, body & status code from Spring 5 WebClient ClientResponse. I do not want to use block() method as it will convert it into sync call. I am able to get responsebody pretty easily using bodyToMono. Also, I am getting status code, headers & body if I am just returning ClientResponse but I need to process response based on statusCode & header

How to extract response header & status code from Spring 5 WebClient ClientResponse

淺唱寂寞╮ 提交于 2020-01-03 11:33:19
问题 I am new to Spring Reactive framework & trying to convert Springboot 1.5.x code into Springboot 2.0. I need to return response header after some filtering, body & status code from Spring 5 WebClient ClientResponse. I do not want to use block() method as it will convert it into sync call. I am able to get responsebody pretty easily using bodyToMono. Also, I am getting status code, headers & body if I am just returning ClientResponse but I need to process response based on statusCode & header

Prometheus Endpoint Not Working Spring Boot 2.0.0.RC1 Spring Webflux enabled

a 夏天 提交于 2020-01-03 10:45:39
问题 I followed the documentation here (https://docs.spring.io/spring-boot/docs/2.0.0.RC1/reference/htmlsingle/#production-ready-endpoints-enabling-endpoints) and made sure application.yml file has the below management: metrics: export: prometheus: enabled: true endpoints: web: expose: health, info, httptrace, metrics, threaddump, mappings, prometheus As per the documentation (https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/actuator-api/html/#prometheus) the following doesn't work. curl

Multiple Authentication strategy for Spring Reactive Webflux microservices

蹲街弑〆低调 提交于 2020-01-02 23:18:08
问题 This is in continuation of the question, Multiple WebsecurityConfigurerAdapter, I was able to successfully make two WebsecurityConfigurerAdapter work with two different security configurations. Now there are few microservices which have been upgraded to SpringBoot 2 with reactive webflux framework. Here too I want to do the same, where all apis are secured with jwt token and actuator apis are secured using basic auth. Here is my code ActuatorSecurityConfig @ConditionalOnWebApplication(type =

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