What are worker threads, and what is their role in the reactor pattern?

The Reactor pattern is used with worker threads to overcome a common scenario in applications: You need to do a lot of work eventually but you don’t know which work and when and creating threads is an expensive operation. The idea is that you create a lot of threads which don’t do anything at first. … Read more

How to set a timeout in Spring 5 WebFlux WebClient

To set the read and connect timeout I use the method below, because the SO_TIMEOUT option is not available for channels using NIO (and giving the warning Unknown channel option ‘SO_TIMEOUT’ for channel ‘[id: 0xa716fcb2]’) ReactorClientHttpConnector connector = new ReactorClientHttpConnector( options -> options.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 2000) .compression(true) .afterNettyContextInit(ctx -> { ctx.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS)); })); return WebClient.builder() .clientConnector(connector) … Read more

Netflix RxJava vs Spring Reactor [closed]

There isn’t a single document that lists the pros and cons of RxJava versus Reactor. We don’t see it being a mutually exclusive relationship. If you need the holistic Reactive approach of RxJava Observables, then use that and maybe add Reactor as a Scheduler implementation to get the high speed dispatching. If you’re more interested … Read more

Spring Webflux : Webclient : Get body on error

I prefer to use the methods provided by the ClientResponse to handle http errors and throw exceptions: WebClient.create() .post() .uri( url ) .body( bodyObject == null ? null : BodyInserters.fromValue( bodyObject ) ) .accept( MediaType.APPLICATION_JSON ) .headers( headers ) .exchange() .flatMap( clientResponse -> { //Error handling if ( clientResponse.statusCode().isError() ) { // or clientResponse.statusCode().value() >= … Read more