Questions tagged [reactor]

The reactor design pattern is an event handling pattern for handling service requests delivered concurrently to a service handler by one or more inputs. The service handler demultiplexes the incoming requests and dispatches them synchronously to the associated request handlers.

735 questions
129
votes
1 answer

Correct way of throwing exceptions with Reactor

I'm new to project Reactor and reactive programming in general. I'm currently working on a piece of code similar to this: Mono.just(userId) .map(repo::findById) .map(user-> { if(user == null){ throw new…
davioooh
  • 23,742
  • 39
  • 159
  • 250
100
votes
3 answers

Akka or Reactor

I am in the process of starting a new project (java-based). I need to build it as a modular, distributed and resilient architecture. Therefore I would like to have the business processes to communicate among themselves, be interoperable, but also…
David Riccitelli
  • 7,491
  • 5
  • 42
  • 56
49
votes
14 answers

Spring Webflux : Webclient : Get body on error

I am using the webclient from spring webflux, like this : WebClient.create() .post() .uri(url) .syncBody(body) .accept(MediaType.APPLICATION_JSON) .headers(headers) .exchange() …
adrien le roy
  • 823
  • 2
  • 7
  • 12
41
votes
1 answer

Netflix RxJava vs Spring Reactor

I am evaluating reactor library for using it in our project. I googled a lot but couldn't find the difference(pros /cons) between Netflix's RxJava and Spring's Reactor API. can someone please help me in deciding or provide some pointers? Thanks.
Roy
  • 569
  • 1
  • 4
  • 6
31
votes
10 answers

How to set a timeout in Spring 5 WebFlux WebClient

I'm trying to set timeout on my WebClient, here is the current code : SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); ClientHttpConnector httpConnector = new…
Seb
  • 3,602
  • 8
  • 36
  • 52
30
votes
2 answers

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

I'm trying to understand the Reactor pattern (concurrent), but in many examples they are talking about 'worker threads'. What are worker threads? In what way do they differ from 'normal' threads? And what is their role in the reactor pattern?
Jon
  • 457
  • 1
  • 5
  • 11
26
votes
1 answer

How does backpressure work in Project Reactor?

I've been working in Spring Reactor and had some previous testing that made me wonder how Fluxes handle backpressure by default. I know that onBackpressureBuffer and such exist, and I have also read that RxJava defaults to unbounded until you define…
James Gan
  • 407
  • 1
  • 6
  • 11
26
votes
2 answers

How does Python's Twisted Reactor work?

Recently, I've been diving into the Twisted docs. From what I gathered, the basis of Twisted's functionality is the result of it's event loop called the "Reactor". The reactor listens for certain events and dispatches them to registered callback…
deadlock
  • 7,048
  • 14
  • 67
  • 115
22
votes
2 answers

Stop twisted reactor on a condition

Is there a way to stop the twisted reactor when a certain condition is reached. For example, if a variable is set to certain value, then the reactor should stop?
gmemon
  • 2,573
  • 5
  • 32
  • 37
19
votes
2 answers

Mono> difference with Flux in Spring webflux

My understand is Mono> is a synchronized Flux and Flux could not be a rest api response. Am I right? If not, what's the different between Mono> and Flux or could a Flux could be a rest api response in some where ?
zhuochen shen
  • 1,673
  • 4
  • 16
  • 24
19
votes
2 answers

Multiple reactors (main loops) in one application through threading (or alternative means)

I've got an idea for an app I'd like to work on to learn a bit more about Twisted and WebSockets. I was thinking of integrating a previously written IRC Bot into a web application. As far as I can see it, I would need three reactors to make it…
Mike Trpcic
  • 25,305
  • 8
  • 78
  • 114
18
votes
1 answer

How are Mono and Mono.empty() different

As per my understanding, in Spring WebFlux reactor Mono refers for a void Mono Mono.empty() refers to void, as calling anything over this gives a null pointer. How do these stand different in their usage ?
Aditya Rewari
  • 2,343
  • 2
  • 23
  • 36
17
votes
2 answers

How to convert List> to Mono>?

I have a method that returns Mono: interface Processor { Mono process(Input input); } And I want to execute this processor method for a collection: List inputs = // get inputs Processor processor = // get…
Ilya Zinkovich
  • 4,082
  • 4
  • 25
  • 43
15
votes
2 answers

Difference between Infinite Java Stream and Reactor Flux

I am trying to figure out the conceptual differences between an infinite Stream and an infinite Flux respectively (if there are any). For that matter, I have come up with the following examples for an infinite Stream/Flux @Test public void…
Felix
  • 171
  • 1
  • 5
12
votes
2 answers

Why Reactor Mono is recognized as an empty Mono?

Here is the piece of code @Test public void test_mono_void_mono_empty() { Mono.just("DATA") .flatMap(s -> Mono.just(s.concat("-") .concat(s)) .doOnNext(System.out::println) …
Serhii Povísenko
  • 3,352
  • 1
  • 30
  • 48
1
2 3
48 49