spring-webflux

How to limit request payload size using Spring Webflux?

时光毁灭记忆、已成空白 提交于 2019-12-22 00:17:37
问题 Using Spring Webflux, I need to limit the payload size of incoming HTTP requests (e.g. to say 5MB). Is this something configurable out-of-the-box? If not, which APIs can we use to implement this behavior (e.g. return a 413 if the payload is too big). 回答1: I guess you want to do this to prevent Denial Of Service attacks by malicious or misbehaving clients. The usual recommendation is to not directly connect HTTP application servers to the Internet, but instead via an HTTP reverse proxy server

How to intercept a request when using SpringBoot WebClient

允我心安 提交于 2019-12-21 21:20:48
问题 I am trying to use the WebClient to call my restServices. Previously on RestTemplate , we had ClientHttpRequestInterceptor defined and attached to the RestTemplate to intercept and modify the requests. With the WebClient , is there a way to do the same ? Thanks, -Sreeni 回答1: When you are using the WebClient Builder you can pass in implementations of the ExchangeFilterFunction interface using the filter() method. This is the equivalent of the ClientHttpRequestInterceptor for `RestTemplate.

How to use Jaeger with Spring WebFlux?

依然范特西╮ 提交于 2019-12-21 20:24:21
问题 We are trying to go reactive with Webflux. We are using Jaegar with Istio for instrumentation purposes. Jaegar understands Spring MVC endpoints well, but don't seem to work at all for WebFlux. I am looking for suggestions to make my webflux endpoints appear in Jaeger. Thanks in advance. 回答1: The best way to move forward in order to use Jaegar is NOT TO USE JAEGAR CLIENT! Jaegar has the ability to collect Zipkin spans: https://www.jaegertracing.io/docs/1.8/getting-started/#migrating-from

Spring WebFlux, unit testing Mono and Flux

非 Y 不嫁゛ 提交于 2019-12-21 19:25:41
问题 Interested in reactive programming, I played a bit with the Building a Reactive RESTful Web Service guide. And wanted to move forwrad and add some unit tests. I tried to test my handler ( RouterFunction ) with plain Junit/Mockito test. But, because it is reactive, the handler returns a Mono<ServerResponse> . So I had to block() it to test the ServerResponse status but was not able to extract his body to test it. While searching the web for a solution, it seems that all the samples are using

Configured ObjectMapper not used in spring-boot-webflux

廉价感情. 提交于 2019-12-21 09:08:47
问题 I have mixins configured in my objectmapperbuilder config, using the regular spring web controller, the data outputted according to the mixins. However using webflux, a controller with a method returning a Flow or Mono have the data serialized like if the objectmapper a default one. How to get webflux to enforce an objectmapper configuration to be used ? sample config: @Bean JavaTimeModule javatimeModule(){ return new JavaTimeModule(); } @Bean Jackson2ObjectMapperBuilderCustomizer

Is really necessary to use Hystrix with reactive spring boot 2 application?

巧了我就是萌 提交于 2019-12-21 06:18:53
问题 I'm working in a project in which we are moving some of ours microservices from Spring-MVC to Spring-Webflux to test the reactive paradigm. Looking for some help in the github repository of hystrix we've noted that the project have no commits since a year ago, and it's based in RxJava, so there are some incompatibilities with project-reactor. We're having some issues using Hystrix, particulary that the annotations from "Javanica" doesn't work and our developers need to use HystrixCommands

JDBC with Webflux - how to dispatch to container thread

…衆ロ難τιáo~ 提交于 2019-12-21 05:41:15
问题 I am working on a small proof-of-concept with webflux. In one part of my application I would like to communicate with a database (via JDBC) which is blocking and is not a good fit for reactor. Nevertheless for this proof-of-concept, I am thinking of following trick: Define a dedicated thread pool (let's call it DBThreadPool ) as ExecutorService with a fixed number of threads that equal JDBC connection pool size. Wrap that pool in Reactor Scheduler (named dbScheduller ) Wrap blocking call

Detecting end of Flux data v.s. error

徘徊边缘 提交于 2019-12-21 05:14:39
问题 Currently looking at SSE using Angular 5 and Spring 5 webflux. The basic application is working correctly, but whilst investigating error handling we've noticed that the EventSource in the angular application doesn't see any difference between spring closing the connection due to reaching the end of the Flux stream of data, and an error occuring (e.g. terminating the application mid transfer). The examples we've based our investigations on are the following. https://thepracticaldeveloper.com

Webflux websocketclient, How to send multiple requests in same session[design client library]

房东的猫 提交于 2019-12-20 18:46:19
问题 TL;DR; We are trying to design a WebSocket server using spring webflux WebSocket implementation. The server has usual HTTP server operations e.g. create/fetch/update/fetchall . Using WebSockets we were trying to expose one endpoint so the clients could leverage a single connection for all sort of operations, given WebSockets are meant for this purpose. Is it a right design with webflux and WebSockets? Long Version We are starting a project which is going to use reactive web sockets from

Webflux websocketclient, How to send multiple requests in same session[design client library]

天涯浪子 提交于 2019-12-20 18:46:11
问题 TL;DR; We are trying to design a WebSocket server using spring webflux WebSocket implementation. The server has usual HTTP server operations e.g. create/fetch/update/fetchall . Using WebSockets we were trying to expose one endpoint so the clients could leverage a single connection for all sort of operations, given WebSockets are meant for this purpose. Is it a right design with webflux and WebSockets? Long Version We are starting a project which is going to use reactive web sockets from